Skip to content

fix(fetch): close the connection when a null body status response has content - #6218

Merged
mcollina merged 1 commit into
mainfrom
fetch-205-close-connection
Nov 17, 2026
Merged

mcollina merged 1 commit into
mainfrom
fetch-205-close-connection

Conversation

@mcollina

Copy link
Copy Markdown
Member

A 205 (Reset Content) response must not carry content, but HTTP/1.1 framing still allows one (RFC 9112 §6.3 only makes HEAD, 1xx, 204 and 304 responses end at the headers), so llhttp correctly parses a body when the server sends Transfer-Encoding: chunked or a non-zero Content-Length. Fetch exposes these responses with a null body and silently drained the content, so a server that never finished the body kept the connection busy until bodyTimeout, and the caller had no body stream to cancel.

When content arrives on a null-body-status response, fetch now aborts the dispatch, which closes the connection, and ignores the resulting error because the response has already been delivered without a body. A 205 without content keeps reusing the connection.

… content

A 205 response must not carry content, but HTTP/1.1 framing still allows a
body, and fetch disregards it. Instead of keeping the connection busy until
the server finishes sending content nobody can read, abort the dispatch as
soon as content arrives. 205 responses without content keep reusing the
connection.
@codecov-commenter

codecov-commenter commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.68%. Comparing base (046bb4c) to head (14749c5).
⚠️ Report is 52 commits behind head on main.

Files with missing lines Patch % Lines
lib/web/fetch/index.js 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6218      +/-   ##
==========================================
+ Coverage   91.61%   91.68%   +0.06%     
==========================================
  Files         113      113              
  Lines       44044    44481     +437     
==========================================
+ Hits        40351    40781     +430     
- Misses       3693     3700       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@mcollina
mcollina merged commit 3d170a3 into main Nov 17, 2026
38 checks passed
@mcollina
mcollina deleted the fetch-205-close-connection branch November 17, 2026 15:57
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
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