Skip to content

fix(api): preserve request AsyncLocalStorage context for onInfo in stream and pipeline - #6267

Open
mcollina wants to merge 1 commit into
mainfrom
fix/oninfo-als-stream-pipeline
Open

mcollina wants to merge 1 commit into
mainfrom
fix/oninfo-als-stream-pipeline

Conversation

@mcollina

Copy link
Copy Markdown
Member

#6208 fixed request() so that the onInfo callback for informational (1xx) responses runs in the AsyncResource context of the request that issued it. stream() and pipeline() were not updated and still called onInfo directly, so on a shared connection (for example several requests multiplexed over one HTTP/2 session) onInfo could observe the AsyncLocalStorage store of whichever request opened the connection.

This wraps both calls in runInAsyncScope, matching request() and the other user callbacks in these handlers, and adds regression tests for stream() and pipeline() over a shared HTTP/2 Client. The upgrade and connect handlers have no informational callback and already wrap their callbacks.

…ream and pipeline

#6208 made request() invoke onInfo through runInAsyncScope so that
informational (1xx) responses are delivered in the requesting request's
AsyncResource context. stream() and pipeline() still called onInfo
directly, so on a shared connection the callback could observe the
AsyncLocalStorage store of whichever request opened the connection.

Wrap both calls in runInAsyncScope, matching request() and the other
user callbacks in these handlers.
@codecov-commenter

codecov-commenter commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (f7a6f8f) to head (0774288).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6267   +/-   ##
=======================================
  Coverage   91.78%   91.79%           
=======================================
  Files         113      113           
  Lines       44920    44920           
=======================================
+ Hits        41230    41234    +4     
+ Misses       3690     3686    -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants