Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- 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
28.0.0
What operating system are you using?
Windows
Operating System Version
Windows 10 22H2
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
- Clone https://github.com/connor4312/electron-early-break-bug, and open it in VS Code
- In the Debug view, enable break on Caught Exceptions
- Hit F5. Open a new window.
- Expect to break in renderer.js
Actual Behavior
The runtime does not break at that line, and instead gets a bit broken (see below :P)
Testcase Gist URL
No response
Additional Information
What actually happens is the runtime breaks on internals in the ESM loader. This is not very pretty if it were to be exposed to the user, but it's fine and expected. However, the runtime then rapidly resumes and pauses on multiple exception sites, without the debugger asking it to. Instead, I would expect it to remain paused on the first uncaught exception until a client asks to resume. These are logs from the debugger, found in log.txt (and browsable here) in the example, note that it's receiving debugger state changes but not sending anything:
(The rapid pause/resumes are not something the VS Code debugger handles very well, so the UI gets into a torn state)
I observed very similar behavior inside the VS Code codebase when dealing with floating windows and user-defined breakpoints. I haven't attempted to make an isolated case of that, perhaps it's the same root cause.
Unfortunately I had some trouble trying to get a standalone fiddle to work, perhaps there's some timing component that the vscode debugger triggers.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields👍 Does Not Block Stable
- StatusShow more project fields👍 Does Not Block Stable
- StatusShow more project fields👍 Does Not Block Stable

Activity
electron-issue-triage commentedon Apr 8, 2024
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!
connor4312 commentedon Apr 8, 2024
bump
electron-issue-triage commentedon Jul 8, 2024
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 Aug 7, 2024
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.
5 remaining items
deepak1556 commentedon Feb 10, 2025
I tried to repro with the debugger module but haven't been successful to see the flow of pause and resume events that was seen in the above repro with vscode debugger,
Then I realized this might have to do with multiple contexts, I disabled context isolation and let the preload script run in the same context as the renderer, the vscode debugger was able to pause fine.
I attempted to trace how the flow looks with multiple contexts between devtools and vscode debugger using the following trace args
browser,blink,devtools,renderer,disabled-by-default-blink.debug,disabled-by-default-v8.inspector. The main difference I see is the call to Debugger.setBlackBoxExecutionContexts in the case of devtools.I haven't confirmed yet if the execution contexts passed in that call correspond to the preload script context (will do that shortly) but behavior wise I do see that devtools does not set breakpoints for exceptions from the preload context, so I wonder if this could be the reason for the strange behavior in vscode debugger ?
deepak1556 commentedon Feb 10, 2025
Yeah the call was definitely made for the preload script context https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/models/bindings/IgnoreListManager.ts;l=134-149
executionContext.isDefault : false.But I think now, this is unrelated to the bug. Went back and changed the ignore list in devtools to include content scripts and devtools is able to break in preload script caught exceptions.
deepak1556 commentedon Feb 10, 2025
Running with a debug build shows the following crash,
deepak1556 commentedon Feb 10, 2025
We receive
Page.waitForDebuggerfrom the client which ends up setting theWebScopedPagePauserin https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc;l=244-265However, we seem to continue the execution of preload scripts since the pause is not plumbed into the Node.js integration which inturn causes the suspended document loading to resume before
Runtime.runIfWaitingForDebuggeris received.deepak1556 commentedon Feb 10, 2025
Yeah that seems like the issue, as a confirmation I delay the processing of Node.js callbacks when the page is paused and that fixes it
nikwen commentedon Feb 12, 2025
@deepak1556 For the preload issue you identified, see also #45399.
deepak1556 commentedon Feb 12, 2025
Thanks @nikwen but I think the two issues are unrelated. This one particularly affects esm preload in non sandboxed renderers. I have some more clarity on how the stack #40734 (comment) got to be.
For me it was confusing how we entered
blink::NavigationBodyLoader::OnReadablefrom gin_helper since we don't have any explicit callbacks set in//electron. Capturing the missing V8 stacks helped clarify, the flow wasLocalFrame::OnPageLifecycleStateUpdatedand in turn defers the document loading inLocalFrame::SetContextPausedElectronRendererClient::DidCreateScriptContextand we also defer the loading of the document to ensure preload scripts gets loaded firstelectron/shell/renderer/electron_renderer_client.cc
Lines 104 to 109 in 50d1c80
NavigationBodyLoader::SetDefersLoadingwhich will bail early since the loading state matches that set in step 1)ElectronRendererClient::UndeferLoadviaelectron/lib/renderer/init.ts
Line 165 in 50d1c80
To properly address this following needs to be validated,
DidInstallConditionalFeaturesget triggered while page is in paused state ? Is this from the originalabout:blankpage ? then we are looking at a race conditionScopedPagePauser