Skip to content

http2: finish pending writes after stream close#63439

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

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.

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