Skip to content

http2: finish pending writes after stream close#63439

Closed
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:flaky-test-http2-close-while-writing-2
Closed

http2: finish pending writes after stream close#63439
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:flaky-test-http2-close-while-writing-2

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 19, 2026

This fixes a race where an HTTP/2 stream can close while writes are still
queued. In that state, pending write callbacks could be left unresolved, which
kept the test process alive until timeout.

The fix completes pending write callbacks when nghttp2 closes the stream and
prevents additional data from being queued once the stream is closed.

The existing regression test now also verifies that all server-side write
callbacks run before the stream closes.

Fixes: #58252

Tested with:

  • python3 tools/test.py parallel/test-http2-close-while-writing
  • python3 tools/test.py --repeat=1000 parallel/test-http2-close-while-writing
  • python3 tools/test.py --repeat=10000 parallel/test-http2-close-while-writing

Assisted-by: openai:gpt-5.5

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 19, 2026
@trivikr trivikr force-pushed the flaky-test-http2-close-while-writing-2 branch 2 times, most recently from 2bdb909 to 125b092 Compare May 19, 2026 19:23
Flush pending Http2Stream write callbacks when nghttp2 closes the
stream but JS keeps it alive to finish readable-side cleanup. Also
avoid queueing additional writes once the stream is closed.

Fixes: nodejs#58252

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@trivikr trivikr force-pushed the flaky-test-http2-close-while-writing-2 branch from 125b092 to 58e9183 Compare May 19, 2026 19:40
@lpinca
Copy link
Copy Markdown
Member

lpinca commented May 19, 2026

See also #63249

As a happy side bonus, as part of this work I hunted down the underlying issue for #58252: buggy cleanup of reset streams.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.06%. Comparing base (0b5b189) to head (58e9183).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/node_http2.cc 84.61% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #63439   +/-   ##
=======================================
  Coverage   90.06%   90.06%           
=======================================
  Files         714      714           
  Lines      225918   225931   +13     
  Branches    42734    42739    +5     
=======================================
+ Hits       203464   203480   +16     
- Misses      14232    14233    +1     
+ Partials     8222     8218    -4     
Files with missing lines Coverage Δ
lib/internal/http2/core.js 95.19% <100.00%> (+<0.01%) ⬆️
src/node_http2.h 91.71% <ø> (+0.09%) ⬆️
src/node_http2.cc 82.09% <84.61%> (+<0.01%) ⬆️

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

@trivikr trivikr closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parallel/test-http2-close-while-writing is flaky

3 participants