Skip to content

http2: fix async context loss when trailers carry END_STREAM#63814

Open
orgads wants to merge 1 commit into
nodejs:mainfrom
orgads:http2-async-trailers
Open

http2: fix async context loss when trailers carry END_STREAM#63814
orgads wants to merge 1 commit into
nodejs:mainfrom
orgads:http2-async-trailers

Conversation

@orgads

@orgads orgads commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The previous fix (f67e45e) wrapped header/response event dispatch in reqAsync.runInAsyncScope(), but missed the stream.push(null) call that triggers the 'end' event. When END_STREAM arrives on a trailing HEADERS frame (as gRPC does), the 'end' event fires in the session's async context instead of the request's context.

Wrap the stream.push(null) at end-of-stream in reqAsync.runInAsyncScope() so that the 'end' event preserves the correct AsyncLocalStorage context.

Refs:

@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 Jun 9, 2026
The previous fix (f67e45e) wrapped header/response event dispatch in
reqAsync.runInAsyncScope(), but missed the stream.push(null) call that
triggers the 'end' event. When END_STREAM arrives on a trailing HEADERS
frame (as gRPC does), the 'end' event fires in the session's async
context instead of the request's context.

Wrap stream.push(null) at end-of-stream in reqAsync.runInAsyncScope()
so that the 'end' event preserves the correct AsyncLocalStorage context.

Refs: nodejs#55460
Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
@orgads

orgads commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

The macOS failure looks unrelated to my change.

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.

3 participants