Skip to content

http: send queued informational responses first - #67959

Open
inoway46 wants to merge 1 commit into
nodejs:mainfrom
inoway46:http-fix-pipelined-header-order
Open

inoway46 wants to merge 1 commit into
nodejs:mainfrom
inoway46:http-fix-pipelined-header-order

Conversation

@inoway46

@inoway46 inoway46 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

When a pipelined response is waiting for its socket, _send() can place the final response header ahead of a queued 100 Continue if the first body chunk is a Buffer. Use _writeRaw() to preserve their order. The regression test checks string, Buffer, and Uint8Array bodies.

Benchmark

http/simple.js showed no statistically significant throughput change for ordinary 1 KiB responses on an Apple M5 Pro (macOS arm64, autocannon 8.0.0).

Body Parent (req/s) PR (req/s) Change (95% CI)
Buffer 92,473 93,034 +0.61% (−0.40% to +1.62%)
String 92,593 92,965 +0.40% (−0.62% to +1.42%)

With BASE_NODE and PR_NODE pointing to release builds of 408fdc5 and 65d3924, respectively, and autocannon on PATH, run from the repository root:

"$BASE_NODE" benchmark/compare.js --old "$BASE_NODE" --new "$PR_NODE" \
  --filter simple.js --set benchmarker=autocannon \
  --set len=1024 --set chunks=1 --set chunkedEnc=0 \
  --set c=50 --set duration=5 --runs 20 --analyze http

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues and PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Dec 2, 2026
@inoway46
inoway46 marked this pull request as ready for review December 2, 2026 06:23
@inoway46
inoway46 force-pushed the http-fix-pipelined-header-order branch from 665a1c1 to 0f1e5dd Compare December 2, 2026 06:28
When the first body chunk was not a utf8 or latin1 string, the header
was put at the front of the output queue. If a pipelined response was
still waiting for its socket and an informational response such as
100 Continue had already been queued, the header was sent before it.

Append the header with _writeRaw() instead, as is already the case
for string chunks. This also removes the duplicated accounting of
the pending output size.

Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: Claude Code
@inoway46
inoway46 force-pushed the http-fix-pipelined-header-order branch from 0f1e5dd to 65d3924 Compare December 2, 2026 07:10
@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (408fdc5) to head (65d3924).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67959      +/-   ##
==========================================
+ Coverage   90.57%   90.58%   +0.01%     
==========================================
  Files         802      802              
  Lines      286674   286857     +183     
  Branches    55378    55400      +22     
==========================================
+ Hits       259655   259853     +198     
+ Misses      17125    17093      -32     
- Partials     9894     9911      +17     
Files with missing lines Coverage Δ
lib/internal/http/outgoing.js 97.82% <100.00%> (-0.21%) ⬇️

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues and PRs related to the http subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants