DebugMCP icon indicating copy to clipboard operation
DebugMCP copied to clipboard

Standalone breakpoint tools fail after the first debug session ends

Open Movoid opened this issue 2 months ago • 1 comments

Summary

In standalone CLI mode, breakpoint tools fail after the first debug session ends because the session's initialized flag is not reset.

Reproduction

  1. Start a fresh debugmcp 0.1.0 MCP server with any DAP adapter (reproduced with debugpy 1.8.22).
  2. Call add_breakpoint, then start_debugging; the breakpoint works.
  3. Let the program exit or call stop_debugging.
  4. Call add_breakpoint before starting the next session.

Actual result:

Error adding breakpoint: Error: No active standalone debug session.

Expected: the breakpoint is stored and synchronized when the next session starts, as it is before the first session.

remove_breakpoint and clear_all_breakpoints are affected by the same state leak.

Root cause

startDebugging() sets initialized = true. The terminated/exited handlers and stopDebugging() clear the client and mark the state terminated, but do not reset initialized.

The next breakpoint change therefore calls syncBreakpoints(), which calls requireClient() after the client is gone.

Resetting initialized = false whenever a session terminates or its client is closed fixes the lifecycle mismatch.

Movoid avatar Sep 27 '26 00:09 Movoid

@Movoid Thanks for the clear reproduction and root-cause analysis. This is fixed in PR #162, now merged into main: https://github.com/microsoft/DebugMCP/pull/162

The standalone executor now clears its initialization flag when a session terminates or its adapter is closed, including explicit stop, disposal, and failed startup/disconnect cleanup. Adding, removing, and clearing breakpoints between sessions no longer attempts to contact an inactive adapter. Saved breakpoint changes are synchronized when the next session starts; active-session synchronization is preserved.

The PR also bumps the standalone npm package to 0.1.2. This confirms the fix is merged; it does not confirm that the new npm version has been published.

GitHub automatically closed this issue when #162 merged. If the problem persists after installing a published version containing this fix, please open a new issue with the installed package/adapter versions and reproduction steps.

ozzafar avatar Sep 27 '26 12:09 ozzafar