Skip to content

Fix debug session not terminating when browser closed from elevated VS#2327

Merged
connor4312 merged 1 commit intomicrosoft:mainfrom
joj:fix/unelevated-browser-disconnect
Mar 10, 2026
Merged

Fix debug session not terminating when browser closed from elevated VS#2327
connor4312 merged 1 commit intomicrosoft:mainfrom
joj:fix/unelevated-browser-disconnect

Conversation

@joj
Copy link
Copy Markdown
Member

@joj joj commented Mar 9, 2026

When VS runs as Administrator, Chrome/Edge is launched unelevated via the DAP launchUnelevatedRequest. This creates a NonTrackedBrowserProcess with no PID and a never-firing onExit event. When the user closes the browser, the CDP connection is lost, but the reconnection retry loop runs forever because the process exit event never fires to cancel it.

Fix: limit CDP reconnection retries to 3 attempts for non-tracked processes (identified by pid === undefined). Tracked processes continue to retry indefinitely as before, since their exit event reliably stops the loop.

@joj joj requested a review from connor4312 March 9, 2026 21:30
@joj joj force-pushed the fix/unelevated-browser-disconnect branch from e1f85e7 to e4f0ea3 Compare March 10, 2026 19:22
When VS runs as Administrator, Chrome/Edge is launched unelevated via the
DAP launchUnelevatedRequest. This creates a NonTrackedBrowserProcess with
no PID and a never-firing onExit event. When the user closes the browser,
the CDP connection is lost, but the reconnection retry loop runs forever
because the process exit event never fires to cancel it.

Fix: if launching unelevated, canReconnect is always false

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joj joj force-pushed the fix/unelevated-browser-disconnect branch from e4f0ea3 to 8f50ca7 Compare March 10, 2026 19:24
@connor4312 connor4312 merged commit 7f550c2 into microsoft:main Mar 10, 2026
2 checks passed
@connor4312 connor4312 mentioned this pull request Mar 13, 2026
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