Skip to content

fix(server): keep pages alive when a reuse-mode connection drops - #42461

Closed
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
microsoft:mainfrom
ashrafiucse:fix-37822
Closed

fix(server): keep pages alive when a reuse-mode connection drops#42461
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
microsoft:mainfrom
ashrafiucse:fix-37822

Conversation

@ashrafiucse

@ashrafiucse Ashraf Ali (ashrafiucse) commented Aug 29, 2026

Copy link
Copy Markdown

Summary

  • mark the shared browser as sharedBrowser: true in reuse-browsers mode, so contexts created by a connection are no longer treated as isolated and killed wholesale by the connection cleanup when the connection drops
  • contexts with pages now survive the drop (per the mode's existing design: "Don't close the pages so that user could debug them") and are picked up by the next connection; empty contexts are still cleaned up on disconnect
  • this restores the pre-1.54 behavior where stopping a debug session in the VS Code extension keeps the browser open for inspection and recording (regression traced to 71088f6 by the extension maintainer in the issue)

Fixes #37822

The extension-side hardening (backend teardown on transient zero page count) is in the companion PR: microsoft/playwright-vscode#808

Related: #42458 fixes stale recorder actions leaking between "Record at cursor" sessions (#42218).

In extension mode, test-run connections engage the reuse-browsers mode,
which deliberately keeps pages alive across connections ("Don't close
the pages so that user could debug them"). However, the shared browser
was not marked as shared, so the connection cleanup treated the
contexts created by the connection as isolated and closed them all on
disconnect ("Global context cleanup"), killing the page being debugged.

Mark the browser as shared in reuse-browsers mode, so contexts with
pages survive the connection drop and are picked up by the next
connection. Empty contexts are still cleaned up on disconnect as
before.

This restores the pre-1.54 behavior where stopping a debug session in
the VS Code extension keeps the browser open for inspection and
recording.

Fixes: microsoft#37822
@dgozman

Copy link
Copy Markdown
Collaborator

I don't think we want this particular fix. Let us look into the original issue though.

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.

[Bug]: VS Code Debugging closes browser after stopping

2 participants