Skip to content

Don't orphan the winapp run process when debug teardown races#57

Open
chiaramooney wants to merge 1 commit into
mainfrom
chiaramooney/fix-orphaned-debug-process
Open

Don't orphan the winapp run process when debug teardown races#57
chiaramooney wants to merge 1 commit into
mainfrom
chiaramooney/fix-orphaned-debug-process

Conversation

@chiaramooney

Copy link
Copy Markdown
Collaborator

What

Harden the WinApp debug adapter factory so the winapp run process it spawns is never left orphaned in the background, and the parent debug session is never stopped twice.

Why

The factory launches the app with winapp run and then starts a child debug session that attaches to it. Two teardown races existed:

  1. Leak on startDebugging throw — if starting the child session threw, the outer catch rethrew without killing the spawned runProcess, leaving a background process running after the failed debug attempt.
  2. Double stop — both onDidTerminateDebugSession and runProcess.on('close') could call stopDebugging for the same parent session.

How

  • Consolidate cleanup into a single idempotent teardown() that disposes the terminate listener, kills the run process, and stops the parent session at most once (guarded by a teardownRequested flag).
  • Wrap startDebugging in a try/catch that runs teardown() before rethrowing, so a failed attach never orphans the run process.

Scope

This is a self-contained teardown-hardening bugfix, independent of #32. It touches the same debug-adapter region as PR #55, so a light rebase may be needed depending on merge order.

Testing

  • npm run compile-tsc — clean
  • npm run lint — 0 errors (8 pre-existing warnings)

The WinApp debug adapter factory launches the app via `winapp run` and then
starts a child debug session. Two problems left the run process orphaned or
double-stopped the session:

- If `startDebugging` throws, the outer catch rethrew without killing the
  spawned `runProcess`, leaking a background process.
- The `onDidTerminateDebugSession` handler and the `runProcess.on('close')`
  handler could both call `stopDebugging` for the same session.

Consolidate teardown into a single idempotent `teardown()` that disposes the
listener, kills the run process, and stops the parent session at most once,
and call it on a `startDebugging` throw so the run process is always cleaned up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ce7415c-8966-43ec-ad27-59a68e7ed74b
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.

1 participant