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

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

Open
sneakers-the-rat opened this issue Jan 18, 2024 · 4 comments
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@sneakers-the-rat
Copy link

sneakers-the-rat commented Jan 18, 2024

Website or app

(all sites)

Repro steps

From any page:

const printMessage = (event) => {console.log(event)};
window.addEventListener('message', printMessage);

Since there isn't a place to actually describe the bug, i'll put it here:
sayHelloToBackendManager is set to poll here until backendInitialized is true:

const intervalID = setInterval(() => {
if (backendInitialized) {
clearInterval(intervalID);
} else {
sayHelloToBackendManager();
}
}, 500);

The polling message has a source react-devtools-content-script:

source: 'react-devtools-content-script',

The switch to set backendInitialized = true checks for the message source react-devtools-bridge:

case 'react-devtools-bridge': {
backendInitialized = true;

the react-devtools-bridge sourced message is sent from the backend by whatever invokes this:

but the handleMessageFromPage function returns if the event.source isn't the window object of the page. Presumably the backend does not have the same window object as the page, or else using postMessage() would be pointless:

if (event.source !== window || !event.data) {

The 'react-devtools-bridge' message never flips backendInitialized = true, so the polling never terminates.

This is causing the bitwarden ppl to get a decent amount of heat, and it's actually devtools causing the problem - bitwarden/clients#7575

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

@sneakers-the-rat sneakers-the-rat added Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Jan 18, 2024
@Nathan-Roberts123
Copy link

I don't think that the problem bitwarden/clients#7575 should be fix here in the react source code, because the problem is in the bitwarden source code.

@sneakers-the-rat
Copy link
Author

the bug in bitwarden revealed a bug in devtools. they are both bugs.

@ctrble
Copy link

ctrble commented Apr 2, 2024

I think this is related to #28323. The site I'm testing on is private and I can't share a repro (sorry!), but this issue describes our situation exactly. It's not a React site and the only extension I have running is the React dev tools. When I disable the extension the message and memory leak both go away.

I'm on a Mac running Chrome Version 123.0.6312.87 (Official Build) (arm64).

Screen Shot 2024-04-02 at 11 26 11 AM

@aescobaricc
Copy link

aescobaricc commented Apr 13, 2024

if you are using chrome

  • go to:
    chrome://extensions/

  • pick
    React Developer Tools

  • set option:
    Site access
    Allow this extension to read and change all your data on websites you visit: On Click

Screenshot 2024-04-12 at 20 49 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

No branches or pull requests

4 participants