Skip to content

Inspector proxy: preserve ordering of messages from device#43639

Closed
robhogan wants to merge 1 commit into
facebook:mainfrom
robhogan:export-D55200617
Closed

Inspector proxy: preserve ordering of messages from device#43639
robhogan wants to merge 1 commit into
facebook:mainfrom
robhogan:export-D55200617

Conversation

@robhogan
Copy link
Copy Markdown
Contributor

Summary:
Currently, the react-native/dev-middleware inspector proxy intercepts Debugger.scriptParsed notifications from the target and replaces sourceMapURL with a data uri, via an async fetch from Metro. During this async fetch, other notifications from the debugger may pass through the proxy, which results in the frontend receiving them before Debugger.scriptParsed.

This reordering causes problems in breakpoint resolution and pausing, because Debugger.breakpointResolved and Debugger.paused events may reference scriptIds unknown to the frontend while the corresponding Debugger.scriptParsed is delayed.

In particular, breakpoint UI state and backend state can fall out of sync, and breakpoints hit may open to the incorrect source location.

This diff modifies the proxy to use a simple per-target promise queue to ensure messages are handled in the order they were received from the target.

Changelog:
[General][Fixed] Fix breakpoints opening to incorrect location or disappearing from debugger frontend UI.

Differential Revision: D55200617

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 25, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D55200617

…43639)

Summary:

Currently, the `react-native/dev-middleware` inspector proxy intercepts `Debugger.scriptParsed` notifications from the target and replaces `sourceMapURL` with a data uri, via an async fetch from Metro. During this async fetch, other notifications from the debugger may pass through the proxy, which results in the frontend receiving them before `Debugger.scriptParsed`.

This reordering causes problems in breakpoint resolution and pausing, because `Debugger.breakpointResolved` and `Debugger.paused` events may reference `scriptId`s unknown to the frontend while the corresponding `Debugger.scriptParsed` is delayed. 

In particular, breakpoint UI state and backend state can fall out of sync, and breakpoints hit may open to the incorrect source location.

This diff modifies the proxy to use a simple per-target promise queue to ensure messages are handled in the order they were received from the target.

Changelog:
[General][Fixed] Fix breakpoints opening to incorrect location or disappearing from debugger frontend UI.

Differential Revision: D55200617
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D55200617

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 25, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in ac714b1.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants