fix: connect React Native CDP targets#30
Merged
Conversation
This was referenced Jun 25, 2026
V3RON
approved these changes
Jun 25, 2026
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.
End-user impact
React Native targets exposed through Metro can now be selected by
agent-cdpwithout failing the WebSocket handshake with HTTP 401. This unlocks the existing JS heap usage, heap snapshot, allocation, and leak-triplet workflows for RN/Hermes targets that implement those CDP methods.Users can continue the normal flow:
Compatibility
Chrome and Node targets keep the existing WebSocket behavior. Only React Native target descriptors receive an
Originheader, derived from the discovery URL origin.Existing commands, output formats, daemon state, snapshot artifacts, and saved analysis workflows are unchanged. The docs now call out that React Native/Hermes may expose only a subset of browser CDP and should use heap usage/snapshot workflows when browser-only domains are unsupported.
Risks
The main risk is target-specific: some non-Metro React Native-compatible endpoints might validate Origin differently. The fallback still derives an origin from the WebSocket URL if the discovery source URL is malformed.
Manual testing
Setup used during investigation:
http://127.0.0.1:8081Observed before this fix:
agent-cdp target select <react-native-target>failed withUnexpected server response: 401.Validation performed:
pnpm --filter agent-cdp exec vitest run src/__tests__/transport.test.tspnpm --filter agent-cdp typecheckpnpm --filter agent-cdp formatpnpm --filter agent-cdp lintpnpm --filter agent-cdp buildtarget selectsucceeded against Expo Go 56 and memory commands captured JS heap usage, heap snapshots, snapshot diffs, leak-triplet output, retainers, and allocation hotspots.