fix: make MockAgent work with protocol-aware global dispatchers#5052
Open
fix: make MockAgent work with protocol-aware global dispatchers#5052
Conversation
12974fe to
5f15b44
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5052 +/- ##
==========================================
+ Coverage 93.03% 93.08% +0.04%
==========================================
Files 110 110
Lines 35786 35934 +148
==========================================
+ Hits 33294 33449 +155
+ Misses 2492 2485 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Apr 21, 2026
Member
|
just conflicts on files |
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.
Summary
Fixes the regression where
setGlobalDispatcher(new MockAgent())no longer intercepts Node.js nativefetch()requests.The original regression happened after legacy global-dispatcher consumers started forcing
allowH2: false. That madeAgentroute those requests through a separate HTTP/1-only path, whileMockAgentonly registered mocks for the default origin path.This PR does more than mirror a second mock bucket:
Agentexplicitly protocol-aware internally by separatingMockAgentto use those helpers instead of sharing or depending onAgent's raw pool mapAgentfetch()and protocol-specific mock registrationThis removes the brittle coupling between
AgentandMockAgentaround the HTTP/1-only path and preserves nativefetch()interception.Fixes: #5036