Don't orphan the winapp run process when debug teardown races#57
Open
chiaramooney wants to merge 1 commit into
Open
Don't orphan the winapp run process when debug teardown races#57chiaramooney wants to merge 1 commit into
chiaramooney wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Harden the WinApp debug adapter factory so the
winapp runprocess 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 runand then starts a child debug session that attaches to it. Two teardown races existed:startDebuggingthrow — if starting the child session threw, the outercatchrethrew without killing the spawnedrunProcess, leaving a background process running after the failed debug attempt.onDidTerminateDebugSessionandrunProcess.on('close')could callstopDebuggingfor the same parent session.How
teardown()that disposes the terminate listener, kills the run process, and stops the parent session at most once (guarded by ateardownRequestedflag).startDebuggingin a try/catch that runsteardown()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— cleannpm run lint— 0 errors (8 pre-existing warnings)