Skip to content

Do not end the debug session after a setup snippet - #62

Merged
davidanthoff merged 2 commits into
mainfrom
fix-debug-with-setup
Aug 19, 2026
Merged

Do not end the debug session after a setup snippet#62
davidanthoff merged 2 commits into
mainfrom
fix-debug-with-setup

Conversation

@davidanthoff

Copy link
Copy Markdown
Member

Closes julia-testitems/TestItemRunner.jl#107.

Draft: blocked on julia-vscode/DebugAdapter.jl#122 being released and vendored. The notify_termination keyword does not exist in the DebugAdapter copy under packages/ yet, so this cannot be merged before scripts/update_vendored_packages.jl picks up DebugAdapter 3.2.

The bug

A test item with setup=[...] debugs its snippets and then its own body, as separate debug_code calls on one debug session (TestItemServer.jl:688 and :778).

debug_code sends a terminated event when the code it was given finishes. In DAP that means the debuggee has ended, so the client ends the debug session and sends disconnect — and disconnect_request puts :terminate on the session's command channel. The session was therefore already being torn down by the time the test item's own body was handed to it, and no breakpoint in the item could be hit. Breakpoints inside the snippet worked, which is what made the reported symptom confusing: "breakpoints within a used snippet are working. However, when stepping out of the snippet, the whole testitem again runs without stopping."

I verified this against DebugAdapter directly before writing anything: two debug_code calls on one session produce two terminated events. The regression test for that lives in the upstream PR, where a session can be driven end to end.

The fix

Setup snippets pass notify_termination=false, so only the test item's own body reports termination.

No test on this side — exercising it needs a DAP client attached to the test process, which the upstream test does instead. Verification here is manual in VS Code once the vendored copy is updated.

🤖 Generated with Claude Code

A test item with `setup=[...]` debugs its snippets and then its own body, as
separate `debug_code` calls on one debug session. `debug_code` sends a
`terminated` event when the code it was given finishes, and a client takes that
as "the debuggee has ended" and disconnects — so the session was already gone by
the time the test item's body ran, and no breakpoint in the item was ever hit.
Breakpoints inside the snippet worked, which is what made the symptom confusing.

Snippets now pass `notify_termination=false`, so only the item's own body reports
termination.

Requires DebugAdapter 3.2, which adds the keyword argument
(julia-vscode/DebugAdapter.jl#122), to be released and vendored first.

Closes julia-testitems/TestItemRunner.jl#107
@davidanthoff
davidanthoff marked this pull request as ready for review August 19, 2026 22:28
@davidanthoff
davidanthoff merged commit b26f4dd into main Aug 19, 2026
9 of 11 checks passed
@davidanthoff
davidanthoff deleted the fix-debug-with-setup branch August 19, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debugger does not stop at breakpoint of a testitem when using setup

1 participant