Skip to content

DAP: the debug session stops when one child session of vscode-js-debug terminates (an iframe or a worker ends) #1897

Closed

Description

@leotimus

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

  1. Serve this page on http://127.0.0.1:8766/ (it must also answer on localhost:8766):

    index.html

    <!doctype html>
    <html><body><p id="out">repro</p><script src="app.js"></script></body></html>

    app.js

    console.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.html and worker.js only log a line.

  2. 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 }
  3. 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.

Activity

  1. angelozerr commented on Nov 9, 2026

    @angelozerr
    Contributor

    @leotimus please create a PR

  2. added this to the 0.30.0 milestone on Nov 9, 2026
  3. moved this to In Progress in Java Toolingon Nov 9, 2026
  4. added
    bug
    dap
    on Nov 9, 2026
  5. moved this from In Progress to Done in Java Toolingon Nov 11, 2026
  6. added a commit that references this issue on Nov 11, 2026
    b80ec21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdap

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions