Skip to content

fix(devtools): Enhance message bus with event tagging and spam protec… #62645

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JeanMeche
Copy link
Member

…tion

One common problem encountered by the devtools content script is that it accepted almost any message send over the message bus. Some websites like auth.openai.com were spamming the bus and DDOS the devtools app.

This commit introduces 2 defensives strategies :

  • event tagging : Only Event sent by the devtools app will make it to its backend
  • Bailout out when the event throughput is too high (we're getting spammed).

fixes #62471 #62450 #55854

@ngbot ngbot bot added this to the Backlog milestone Jul 15, 2025
@JeanMeche JeanMeche force-pushed the devtools/spam-protection branch 3 times, most recently from 8e83db9 to 20fa9d5 Compare July 15, 2025 12:52
@JeanMeche JeanMeche force-pushed the devtools/spam-protection branch from 20fa9d5 to b55f820 Compare July 15, 2025 16:15
@JeanMeche
Copy link
Member Author

/gemini review

@angular angular deleted a comment from gemini-code-assist bot Jul 15, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two important defensive mechanisms for the message bus: event tagging to filter out irrelevant messages, and a spam protection mechanism to prevent the devtools from being overwhelmed by high-frequency event streams. The event tagging is implemented correctly across the different message bus types.

My main feedback is on the spam protection logic in content-script.ts. The current implementation has a delay in detection which could still allow a burst of messages to impact the extension. I've provided a suggestion for a more immediate protection strategy. Overall, this is a valuable improvement for the stability of the devtools.

@JeanMeche JeanMeche force-pushed the devtools/spam-protection branch from b55f820 to 54b55af Compare July 15, 2025 16:55
@JeanMeche JeanMeche requested a review from dgp1130 July 17, 2025 18:05
…tion

One common problem encountered by the devtools content script is that it accepted almost any message send over the message bus. Some websites like `auth.openai.com` were spamming the bus and DDOS the devtools app.

This commit introduces 2 defensives strategies :

* event tagging : Only Event sent by the devtools app will make it to its backend
* Bailout out when the event throughput is too high (we're getting spammed).

fixes angular#62471 angular#62450 angular#55854
@JeanMeche JeanMeche force-pushed the devtools/spam-protection branch from 54b55af to e060593 Compare July 17, 2025 18:33
Copy link
Member

@AleksanderBodurri AleksanderBodurri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So happy to see this issue solved. Thanks for this @JeanMeche 🙏


// This is where we listen for messages sent from the Angular DevTools extension to the content script.
// We have some logic to handle spam protection and event tagging.
fromEvent<MessageEvent>(window, 'message')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider: Move the spam protection piece to a different function which invokes a callback and then pass through proxyEventFromWindowToDevToolsExtension to decouple the two pieces.


// This is where we listen for messages sent from the Angular DevTools extension to the content script.
// We have some logic to handle spam protection and event tagging.
fromEvent<MessageEvent>(window, 'message')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: How necessary is the "spam prevention" part of this?

If the page is emitting a bunch of messages and we ignore them, then that feels WAI from a correctness perspective and should be relatively lightweight from a performance perspective. I'm surprised ignoring messages would have a significant enough performance cost to be observable to users. If they're sending so many messages that the act of ignoring them is a performance problem, then that sounds like either a browser issue or the amount of messages in flight should dominate the performance profile and Angular's contribution of ignoring the content should be relatively insignificant.

Is the issue that we're unnecessarily proxying user-messages to DevTools via a "heavyweight" API like chrome.runtime.sendMessage? If so, would just updating from if (event.source === window && event.data) to if (event.source === window && event.data && event.data.__NG_DEVTOOLS_EVENT__) have the same impact for a lot less effort? Do we really need to unsubscribe from the handler in the case it's too noisy?

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 completely hangs Chrome with extremely high CPU / memory usage when visiting openAI auth page
3 participants