http2: fix async context loss when trailers carry END_STREAM · nodejs/node@86b2497 · GitHub
Skip to content

Commit 86b2497

Browse files
orgadsaduh95
authored andcommitted
http2: fix async context loss when trailers carry END_STREAM
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: #55460 Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com> PR-URL: #63814 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 98ca5e9 commit 86b2497

2 files changed

Lines changed: 51 additions & 37 deletions

File tree

‎lib/internal/http2/core.js‎

Lines changed: 5 additions & 1 deletion

‎test/parallel/test-http2-async-local-storage.js‎

Lines changed: 46 additions & 36 deletions

0 commit comments

Comments
 (0)