Skip to content

http2: emit error on canceled streams when aborted event is not emitted#62923

Open
mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina:fix-http2-cancel-stream-error
Open

http2: emit error on canceled streams when aborted event is not emitted#62923
mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina:fix-http2-cancel-stream-error

Conversation

@mcollina
Copy link
Copy Markdown
Member

When a client HTTP/2 stream's writable side is already ended (e.g. GET requests), receiving RST code 8 (NGHTTP2_CANCEL) emitted neither the aborted nor the error event, causing the stream to close silently.

The fix only skips error generation for NGHTTP2_CANCEL when the aborted event was actually emitted.

Fixes: #56627

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Apr 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.65%. Comparing base (58a8e1d) to head (e2f40e3).
⚠️ Report is 127 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/http2/core.js 71.42% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62923      +/-   ##
==========================================
- Coverage   89.69%   89.65%   -0.04%     
==========================================
  Files         706      707       +1     
  Lines      218222   219538    +1316     
  Branches    41768    42103     +335     
==========================================
+ Hits       195731   196833    +1102     
- Misses      14411    14599     +188     
- Partials     8080     8106      +26     
Files with missing lines Coverage Δ
lib/internal/http2/core.js 95.01% <71.42%> (-0.23%) ⬇️

... and 80 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.

@mcollina mcollina force-pushed the fix-http2-cancel-stream-error branch 3 times, most recently from f3dd59d to 53f5f63 Compare April 27, 2026 10:44
When a client HTTP/2 stream's writable side is already ended (e.g.
GET requests), receiving RST code 8 (NGHTTP2_CANCEL) emitted neither
the 'aborted' nor the 'error' event, causing the stream to close
silently. This happened because the 'aborted' event is only emitted
when the writable side is still open, but the NGHTTP2_CANCEL code was
unconditionally excluded from error generation assuming the 'aborted'
event would cover it.

Fix by only skipping error generation for NGHTTP2_CANCEL when the
'aborted' event was actually emitted.

Fixes: nodejs#56627
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina mcollina force-pushed the fix-http2-cancel-stream-error branch from 53f5f63 to e2f40e3 Compare April 28, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http2: confusion with how aborted ClientHttp2Stream is reported

2 participants