Skip to content

[DevTools] Stop polling the backend manager from the content script - #37848

Open
LubabaKhalid wants to merge 1 commit into
react:mainfrom
LubabaKhalid:devtools-stop-polling-backend-manager
Open

LubabaKhalid wants to merge 1 commit into
react:mainfrom
LubabaKhalid:devtools-stop-polling-backend-manager

Conversation

@LubabaKhalid

Copy link
Copy Markdown

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 to message events 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-injected message: 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:

  • Content script first: its hello finds no listener, then the backend manager announces itself and gets a hello back.
  • Backend manager first: its announcement finds no listener, then the content script's hello reaches it.

This removes the interval and the backendInitialized bookkeeping that only existed to stop it, and updates the comment in backendManager.js to match.

How did you test this change?

  • I ran a temporary Jest test (not included in this PR) that loads proxy.js and backendManager.js in jsdom with a mocked chrome API. 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 on main posts 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.js builds the extension in development and production modes.
  • yarn flow dom-browser passes, and ESLint and Prettier pass on the changed files.

I didn't test it in a real browser.

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.
@meta-cla meta-cla Bot added the CLA Signed label Oct 14, 2026
@LubabaKhalid

Copy link
Copy Markdown
Author

@hoxyq @eps1lon could you take a look when you have a moment? This stops the extension's content script from posting a hello message every 500ms on every page without a React DevTools backend, now that the backend manager announces itself when it's injected.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

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

No deployments
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.

[DevTools Bug]: sayHelloToBackendManager continuously and pointlessly polls on every page

1 participant