Skip to content

Handle VM disconnection gracefully and reorder termination logic#626

Merged
wenytang-ms merged 2 commits intomicrosoft:mainfrom
zepedrocosta:main
Apr 30, 2026
Merged

Handle VM disconnection gracefully and reorder termination logic#626
wenytang-ms merged 2 commits intomicrosoft:mainfrom
zepedrocosta:main

Conversation

@zepedrocosta
Copy link
Copy Markdown
Contributor

After the changes in #620 the stop button wasn't working properly. The action wasn't executed and the process just kept running.

The terminate() now is called before detach() when terminating the debuggee, ensuring proper shutdown sequence.

Wrap vm.dispose() in a try/catch to ignore VMDisconnectedException when the VM has already disconnected (e.g. process terminated) to avoid spurious errors during detach. Reorder calls in DisconnectRequestHandler to invoke terminate() before detach() when terminateDebuggee is true and the session is not attached, ensuring the debuggee is terminated prior to detaching.
@zepedrocosta

This comment was marked as resolved.

Wrap debugSession.terminate() in a try/finally so debugSession.detach() is always invoked when terminateDebuggee is true and the session is not attached. This ensures the session is detached even if terminate() throws, avoiding potential dangling sessions. Other detach logic is unchanged.
@wenytang-ms
Copy link
Copy Markdown
Contributor

@zepedrocosta thank you for your contribute!

@wenytang-ms wenytang-ms merged commit 3adbc03 into microsoft:main Apr 30, 2026
4 checks passed
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.

2 participants