Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor[ReactDevToolsBindingsModel]: dont send messages when execution context is destroyed #114

Merged

Conversation

hoxyq
Copy link

@hoxyq hoxyq commented Sep 9, 2024

Summary

Stacked on #113. See this commit.

What is happening currently:

  • When we reload the app via Chrome DevTools, the Runtime domain is going to send Runtime.executionContextDestroyed event first.
  • At this point, React DevTools Frontend (the panels in Chrome DevTools) are going to call bridge.shutdown() in order to destroy the bridge, so that we unsubscribe all listeners and correctly perform clean-up logic.
  • Once bridge.shutdown is called, the Bridge will attempt to send last event shutdown to the Backend to signal that it is being destroyed and so that the other end (Backend) can also perform some cleanup logic.
  • In order to send this message, we are going to schedule a Runtime.evaluate request, which will be executed only after the new Execution Context is created. This results in a state, when the first event that is being received by the RDT Backend after reload is the shutdown event.

Instead of this, we should not attempt to send any events once the Execution Context is destroyed. There might be some issues with this, like clearing up highlights, but I haven't observed them, and we can deal with them via other methods.

Test plan

  1. Reload the app while Components panel is opened and observe no issues.
  2. Inspect Protocol Monitor and observe that no Runtime.evaluate requests are sent between Runtime.executionContextDestroyed and Runtime.executionContextCreated events.

Upstreaming plan

  • This commit should be sent as a patch to the upstream devtools-frontend repo. I've reviewed the contribution guide.
  • This commit is React Native-specific and cannot be upstreamed.

@hoxyq hoxyq merged commit 50a4d4f into main Sep 9, 2024
2 checks passed
@hoxyq hoxyq deleted the react-devtools/dont-send-messages-when-execution-context-destroyed branch September 9, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants