Repository navigation
[DevTools] Stop polling the backend manager from the content script - #37848
Open
LubabaKhalid wants to merge 1 commit into
Open
LubabaKhalid wants to merge 1 commit into
LubabaKhalid wants to merge 1 commit into
Conversation
The proxy content script posted a hello message every 500ms until a backend initialized. The backend manager is only injected once DevTools is opened on a page with React, so on every other page the extension kept posting messages for as long as the page stayed open. The polling only covered the content script being injected before the backend manager. The backend manager now announces itself when it's injected and the content script answers with a hello, so a single hello on injection is enough in either order.
Author
|
The build for this commit did not complete, so there is no size report. See the workflow run for details. Generated by sizebot against 2191cce |
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
Fixes #27992.
The proxy content script runs on every page and posted
{source: 'react-devtools-content-script', hello: true}to the page every 500ms until a backend initialized. The backend manager is only injected once DevTools is opened on a page with React, so on every other page the extension kept posting messages, and any page listening tomessageevents received them for as long as it stayed open.The polling was there for the case where the content script is injected before the backend manager. That case is now covered by the
backend-manager-injectedmessage: the backend manager announces itself when it's injected, and the content script answers with a hello. So a single hello when the content script is injected is enough in either order:This removes the interval and the
backendInitializedbookkeeping that only existed to stop it, and updates the comment inbackendManager.jsto match.How did you test this change?
proxy.jsandbackendManager.jsin jsdom with a mockedchromeAPI. With this change, the backend manager is welcomed in both injection orders, and the content script posts one hello in 10 seconds when there is no backend manager. The same test onmainposts 21 hellos in that time, and both injection orders also work there.yarn test --build --project devtools --release-channel=experimental packages/react-devtools-extensions: 2/2 pass.ignoreList-test.jsbuilds the extension in development and production modes.yarn flow dom-browserpasses, and ESLint and Prettier pass on the changed files.I didn't test it in a real browser.