Repository navigation
Conversation
Requests waiting in the Pool queue were dispatched from whichever callback drained it (another request's connect or drain), so Client#dispatch and the undici:request:create diagnostics channel ran in the wrong AsyncLocalStorage context. Since #5799 every concurrent HTTPS request is queued during ALPN negotiation, which made this hit fetch() by default. Capture the caller's async context when queueing and dispatch inside it. Fixes: #5981 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PU6gYCHEgVgF9WeVje8SXF Signed-off-by: Matteo Collina <hello@matteocollina.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5982 +/- ##
==========================================
+ Coverage 91.53% 91.54% +0.01%
==========================================
Files 113 113
Lines 43597 43614 +17
==========================================
+ Hits 39908 39928 +20
+ Misses 3689 3686 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kettanaito
approved these changes
Oct 9, 2026
kettanaito
left a comment
Contributor
There was a problem hiding this comment.
FWIW, looks good! Thank you so much for covering it promptly.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5981
Problem
Requests that wait in the Pool queue are dispatched later from whichever callback drains it (another request's
connectordrainevent).Client#dispatch, and theundici:request:creatediagnostics channel it publishes, therefore ran in that callback'sAsyncLocalStoragecontext instead of the caller's.This was already the case for saturated pools (e.g.
connections: 1), but since #5799 every concurrent HTTPS request is held in the Pool queue until the first connection completes ALPN negotiation, so it now affectsfetch()against anyhttps:origin by default (h1 and h2 servers alike). MSW relies on this context and broke on Node.js v26.Fix
Queued requests are stored as a small
AsyncResourcesubclass that captures the caller's context, and are dispatched inside it when the queue drains. Requests dispatched directly to a free client are unaffected.BalancedPoolsharesPoolBase, so it is covered too.Tests
test/issue-5981.jscovers HTTPS h1, HTTPS h2 (queued during ALPN) and HTTP Pool withconnections: 1. All three fail without the fix and pass with it.🤖 Generated with Claude Code
https://claude.ai/code/session_01PU6gYCHEgVgF9WeVje8SXF