microsoft / microsoft/playwright

[Bug]: `RenderDocument` introduces `page.close()` hang

Open
#42,068 3 comments 0 reactions 1 assignee View on GitHub

@dgozman is already working on this.

Since Jul 31, 2026.

v1.64
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

### Version

ToT

### Steps to reproduce

```ts
test('should close page while reload is committing', async ({ context, browserName }) => {
test.skip(browserName !== 'chromium');
for (let i = 0; i < 20; i++) {
const page = await context.newPage();
await expect(page.evaluate(() => {
location.reload();
return new Promise(() => {});
})).rejects.toThrow(/navigation/);
await page.close(); // intermittently hangs
}
});
```

### Expected behavior

The test passes fine.

### Actual behavior

`page.close()` hangs. To expose this behaviour, it's important to have the loop inside the test, running it without the loop but with `--repeat-each` doesn't expose it. I suppose it's linked to races within the context or something.

### Additional context

This started at https://github.com/microsoft/playwright/pull/41303.

Discovered through https://github.com/microsoft/playwright-python/pull/3161.

### Environment

```shell
Simon's Mac
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.