You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Page.frameAttached Chrome Devtools Protocol events are not being dispatched #46048
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
35.0.1 (also tested in the latest nightly and 33.0.0)
What operating system(s) are you using?
macOS
Operating System Version
MacOS Sequoia 15.1.1
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Expected Behavior
The Page.frameAttached CDP event should be dispatched when a frame has been attached to its parent.
This event should be fired after rendering an iframe in a given webContents while:
attached to the webContents debugger AND
the Page domain is enabled via debugger.sendCommand('Page.enabled')
Actual Behavior
The event is not fired, despite the above conditions being met. Testing in Chrome itself via the DevTools protocol monitor shows that the event is fired when rendering a similar iframe on a page.
The gist simply logs CDP events after enabling the page domain to create a simple test case.
I've also unsuccessfully tested this with:
cross-origin and same-origin iframes
iframes that are rendered mounted/unmounted dynamically via js
For additional context, I'm investigating this because I'm attempting to integrate playwright with electron for automation use-cases, and playwright listens for the Page.frameAttached CDP event to track frames.
I took a stab at investigating why this might be happening by creating a custom electron build and adding some logs. I don't have a fix but I've been able to outline the basic flow of what is happening:
Page.frameAttached events are initially dispatched from blink here
The event is enqueued/processed/dispatched via mojo IPC from blink -> the browser process here
The IPC event is received in the browser DevToolsSession class here
The browser DevToolsSession class passes the event to the attached electron debugger client here
The electron debugger client emits the event to javascript here
I was able to observe that Page.frameAttached events made it to (2) but no further (it gets enqueued/processed/dispatched but then its gone). Other CDP events in the same domain that are also initially dispatched from blink (e.g. Page.frameDetached) go through this entire flow and are emitted in javascript.
We detach/reattach the session in Debugger::RenderFrameHostChanged. When I remove that logic the Page.frameAttached event makes it all the way though the flow I outlined above and is emitted in js.
I'm going to investigate possible fixes this week. Would love input from folks if anyone has ideas as to how to fix this.
Quick follow up - The reason the Page.frameAttached event is being swallowed is that the page agent / session reconnect asynchronously (see implementation here). The frame gets attached while the reconnection task is ongoing so we lose the event.
I wonder if there is a way to pause messages while we're reconnecting, or if there is a way to resolve the issue fixed by #14475 without disconnecting/reconnecting.
I also wonder if this is causing other subtle bugs in addition to what i've observed.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
We detach/reattach the session in Debugger::RenderFrameHostChanged. When I remove that logic the Page.frameAttached event makes it all the way though the flow I outlined above and is emitted in js.
I'm going to investigate possible fixes this week. Would love input from folks if anyone has ideas as to how to fix this.
I encountered the same issue when using puppeteer-core in electron.After commenting out these three lines of code, it can be used normally.Is there any other negative impact if we remove these three lines of code?
I had to deprioritize this issue and am not sure when i'll be able to continue investigating. The original PR that added the code can be found here: #14475. A good next step would be to investigate if the issue it was fixing is still a problem without the change. Do you have capacity to do that?
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
Activity
brianlyn commentedon Mar 14, 2025
I took a stab at investigating why this might be happening by creating a custom electron build and adding some logs. I don't have a fix but I've been able to outline the basic flow of what is happening:
Page.frameAttachedevents are initially dispatched from blink hereThe event is enqueued/processed/dispatched via mojo IPC from blink -> the browser process here
The IPC event is received in the browser DevToolsSession class here
The browser DevToolsSession class passes the event to the attached electron debugger client here
The electron debugger client emits the event to javascript here
I was able to observe that
Page.frameAttachedevents made it to (2) but no further (it gets enqueued/processed/dispatched but then its gone). Other CDP events in the same domain that are also initially dispatched from blink (e.g.Page.frameDetached) go through this entire flow and are emitted in javascript.brianlyn commentedon Mar 16, 2025
I've narrowed down the problem to this logic
electron/shell/browser/api/electron_api_debugger.cc
Line 82 in 4ad20cc
We detach/reattach the session in
Debugger::RenderFrameHostChanged. When I remove that logic thePage.frameAttachedevent makes it all the way though the flow I outlined above and is emitted in js.I'm going to investigate possible fixes this week. Would love input from folks if anyone has ideas as to how to fix this.
Relevant PR: #14475
brianlyn commentedon Mar 17, 2025
Quick follow up - The reason the
Page.frameAttachedevent is being swallowed is that the page agent / session reconnect asynchronously (see implementation here). The frame gets attached while the reconnection task is ongoing so we lose the event.I wonder if there is a way to pause messages while we're reconnecting, or if there is a way to resolve the issue fixed by #14475 without disconnecting/reconnecting.
I also wonder if this is causing other subtle bugs in addition to what i've observed.
electron-issue-triage commentedon Jun 16, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
brianlyn commentedon Jun 29, 2025
bump
huaxinjiayou commentedon Aug 8, 2025
@brianlyn
I encountered the same issue when using puppeteer-core in electron.After commenting out these three lines of code, it can be used normally.Is there any other negative impact if we remove these three lines of code?
brianlyn commentedon Aug 10, 2025
I had to deprioritize this issue and am not sure when i'll be able to continue investigating. The original PR that added the code can be found here: #14475. A good next step would be to investigate if the issue it was fixing is still a problem without the change. Do you have capacity to do that?
electron-issue-triage commentedon Nov 9, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
electron-issue-triage commentedon Dec 9, 2025
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.