[BUG] "Browser has been closed" error when running test that uses `context.route` and `context.waitForEvent` with playwright vscode extension with "Show browser" enabled
System info
- Playwright Version: 1.30.0
- Operating System: windows 10
- Browser: chromium
Source code
- [X] I provided exact source code that allows reproducing the issue locally.
Config file
// playwright.config.ts
export default {}
Test file (self-contained)
test('asdf', async ({ context, page }) => {
await page.setContent(
"<button onclick=\"window.open('https://www.google.com', '_blank')\">asdf</button>",
)
await context.route(/\/asdf/u, () => {})
const newPagePromise = context.waitForEvent('page')
await page.click('button')
await newPagePromise
})
Steps
- enable "Show browser" in the playwright extension options on vscode's "Testing" tab
- click the gutter run button next to the test
Expected test passes
Actual
"Browser has been closed" error

this only occurs when running the test through the vscode extension with "Show browser" enabled. the test passes when disabling "Show browser" or when running the test with the playwright test command
@DetachHead update Playwright to latest release 1.32.3 and confirm that bug still apears
I tried to reproduce it on macOS, unfortunately I was not able to reproduce it. It might play a role that you are on Windows, are some of your colleagues on Windows by any chance?
Also having a full repro repository might play a role here.
i think the issue was intermittent but i can't seem to reproduce it anymore. will re-open if it happens again
I have the same issue here on Ubuntu 22.04.
Playwright ver 1.33.0.
[1/1] [chromium] › fcnf-1312-multilanguage/checkout.spec.js:33:5 › 001-change-eng-to-indo
1) [chromium] › fcnf-1312-multilanguage/checkout.spec.js:33:5 › 001-change-eng-to-indo ───────────
Test timeout of 30000ms exceeded.
Pending operations:
- page.goto at e2e/fcnf-1312-multilanguage/checkout.spec.js:136:16
Error: page.goto: Browser has been closed
134 |
135 | await test.step('test-with-items-on-cart', async () => {
> 136 | await page.goto('https://someurl.sh', {timeout: 30000});
| ^
137 | await expect(page).toHaveURL(/.*someurl/, {timeout: 30000});
138 | await page.getByRole('link', { name: 'Roma Slai O\'lai Pineapple 192 Gram' }).first().click();
139 | await page.getByRole('button', { name: '1-Click Checkout' }).click();
at /home/imanovski/Project/flik/flik-checkout-e2e/e2e/fcnf-1312-multilanguage/checkout.spec.js:136:16
at /home/imanovski/Project/flik/flik-checkout-e2e/e2e/fcnf-1312-multilanguage/checkout.spec.js:135:14
1 failed
[chromium] › fcnf-1312-multilanguage/checkout.spec.js:33:5 › 001-change-eng-to-indo ────────────
But it's look intermitent.
@rimantoro Do you happen to have a trace, browser logs, or something else that could help? Unfortunately, without a repro there's not much we can do here.
Closing because we lack the information to act on this issue. If you can provide a full repro, please file a new issue by filling the "Bug Report" template, and link to this one.
@dgozman here.s a trace where it happens. might not help though, since the trace doesn't go till the end. the test did run one test step further as shown in vsode