Repository navigation
Description
I found this in August while debugging our web app (a React shell that loads Module Federation
remotes) with vscode-js-debug (pwa-chrome) and LSP4IJ 0.20.1: a page reload ended the whole
debug session, and IntelliJ closed the Chrome window it had started. I have used a local fix
since then. The code is the same on main.
With a minimal page, the trigger is not the reload itself but a target that goes away: a
cross-origin iframe or a worker. A reload of our app destroys such targets.
LSP4IJ main (52f756c), IntelliJ IDEA 2026.2.1, macOS, vscode-js-debug v1.117.0
(dapDebugServer.js), Node 24.19.0, Chrome 157.
Steps to reproduce
-
Serve this page on
http://127.0.0.1:8766/(it must also answer onlocalhost:8766):index.html<!doctype html> <html><body><p id="out">repro</p><script src="app.js"></script></body></html>
app.jsconsole.log('page loaded on ' + location.href); const frame = document.createElement('iframe'); frame.src = 'http://localhost:8766/frame.html'; // cross-origin: its own target document.body.appendChild(frame); const worker = new Worker('worker.js'); setTimeout(() => { frame.remove(); worker.terminate(); }, 3000);
frame.htmlandworker.jsonly log a line. -
Create a DAP run configuration that runs
node <js-debug>/src/dapDebugServer.js ${port} 127.0.0.1,
with this launch configuration:{ "type": "pwa-chrome", "request": "launch", "url": "http://127.0.0.1:8766/", "webRoot": "<folder of the page>", "sourceMaps": true } -
Debug it, and wait 3 seconds.
Expected: the debug session stays, because the page still runs. VS Code keeps it.
Actual: the debug session ends after 3 seconds, when the iframe and the worker go away.
What js-debug sends
js-debug starts a child session per target with startDebugging. When a target goes away, only
its own child sends terminated. A trace of this page with a small DAP client:
0.55s root reverse startDebugging -> child1 (the page)
0.59s child1 reverse startDebugging -> child2 (the iframe)
0.59s child1 reverse startDebugging -> child3 (the worker)
3.58s child1 output: removing the iframe and the worker
3.58s child2 event terminated {}
3.58s child3 event terminated {}
Cause
DAPClient.terminated()
stops the whole debug process for the terminated event of any session:
public void terminated(TerminatedEventArguments args) {
// TODO : manage args.getRestart()
debugProcess.stop();
}Suggested fix
Mark the session as terminated and detach it from its parent. Stop the debug process only when
no session in the tree is alive, and not when args.getRestart() is true. A terminated child
should get no more requests
(pause()
sends one to each child), but it should still be disposed with its parent.
If you agree, I can open a PR.
AI/tooling disclosure: I found this bug while working, and I used Claude Code for the analysis,
the fix, the minimal page and the trace. I reviewed the result and understand the problem.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
angelozerr commentedon Nov 9, 2026
@leotimus please create a PR
fix(dap): keep the debug session while another session of the tree is…
docs: the DAP session tree and the API changes in the change notes fo…
docs: change notes for 0.30.0 (#1941)