Repository navigation
Conversation
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.
Summary
Addresses a small correctness/usability bug with WebSocket events in React Native DevTools.
The bug
Previously, the reported call stack for
Network.webSocketCreatedCDP events starts at theWebSocketconstructor's own frame. DevTools hides that frame while any non-ignore-listed frame exists (i.e. in product code), but for sockets opened entirely from framework code, such as Metro's/hotFast Refresh connection, every frame is ignore-listed and the Initiator column falls back to the top frame, showingWebSocket.js:147.Fix
__NETWORK_REPORTER__.createDevToolsRequestIdnow takes an optionalframesToSkipcount, dropped from the serialized CDP call frames, andWebSocketpasses 1 for its constructor. The top frame is then the caller ofnew WebSocket(), matching Chrome's initiator semantics for a native API, so/hotresolves to metro-runtime'sHMRClient.WebSocket.js, which isn't particularly useful (internals of the WebSocket API itself)HMRClient.js(Metro hot reload client, more useful) ✅ Product call site unchangedNotes
RuntimeTargetDelegate::captureStackTrace(framesToSkip), which the console path already uses to mean the host-function frame that Hermes strips itself.This is the last known bug I had tracked before enabling WS support everywhere in #59683.
Changelog:
[General][Fixed] - React Native DevTools: Fix the initiator of WebSocket connections opened from framework code, such as Metro's Fast Refresh socket, in the Network panel
Test Plan
yarn flow-check, ESLint and Prettier on the changed files.testWebSocketCreatedWithInitiatorFramesToSkip.fuseboxWebSocketEventsEnabled, React Native DevTools Network panel, Initiator column. Product-code sockets were opened from a local RNTester example covering four call-site shapes:/hotWebSocket.js:147HMRClient.js:24new WebSocket()in a press handlerWebSocketExample.js:167WebSocketExample.js:130setTimeoutWebSocketExample.js:180WebSocketsubclass constructorWebSocketExample.js:133