Skip to content

fix(ext/node): pass URL to kOnHeadersComplete when request has no headers - #33831

Merged
littledivy merged 1 commit into
denoland:mainfrom
divybot:claude/test-http-parser
May 4, 2026
Merged

littledivy merged 1 commit into
denoland:mainfrom
divybot:claude/test-http-parser

Conversation

@divybot

@divybot divybot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Enables test-http-parser in node_compat suite.

Test plan

  • cargo test --test node_compat -- test-http-parser

…ders

Enables tests/node_compat/runner/suite/test/parallel/test-http-parser.js

Co-authored-by: Divy Srivastava <me@littledivy.com>

@fibibot fibibot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Subtle but correct fix for an edge case in on_headers_complete. CI fully green at this head (99 success, 1 skipped, 0 fail).

What I verified

The bug: the old skip_flush boolean had two definitions that didn't match what the rest of the code assumed:

let skip_flush = !inner.headers_flushed && !inner.header_fields.is_empty();

A request with no headers (header_fields.is_empty() == true) and no prior flush (headers_flushed == false) would compute skip_flush = false, sending the code down the slow path that passes undefined for headers/url to parserOnHeadersComplete — expecting JS to read from parser._headers/_url. But nothing was ever flushed (the inner if guards on !header_fields.is_empty()), so JS would see no URL.

The fix (binding.rs:464-471, :510) decouples the two semantics:

let on_fast_path = !inner.headers_flushed;
if !on_fast_path && !inner.header_fields.is_empty() {
  // Slow path's optional flush — only fires when there ARE leftover headers
}
// ...
let (headers, url) = if on_fast_path {
  // Fast path: pass header_fields (possibly empty) + url directly
} else {
  // Slow path: pass undefined, JS already has _headers/_url from flush
};

Now:

  • on_fast_path is purely "no prior kOnHeaders flush has happened in this request". Independent of whether the current batch has headers.
  • The URL gets passed regardless of whether header_fields is empty (the bug the PR title fixes).
  • Slow path's flush stays gated on !is_empty() (no point flushing nothing).

The rename skip_flush -> on_fast_path is also a clarity win — the original name was confusing because it answered the wrong question (whether to skip the flush, not which path to take).

Test enable (config.jsonc:1550): parallel/test-http-parser.js — the upstream Node test that exercises kOnHeadersComplete invariants directly via the binding. ✓

No concerns inline — the diff is small enough to walk in one pass and the semantics are clean.

@littledivy
littledivy merged commit 16fff7d into denoland:main May 4, 2026
136 checks passed
littledivy added a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…ders (denoland#33831)

## Summary

Enables `test-http-parser` in node_compat suite.

## Test plan
- [x] `cargo test --test node_compat -- test-http-parser`

Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants