Skip to content

fix(frames): reject context waits when page closes - #43650

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
mainfrom
triage/43647/40348362900-1
Oct 30, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
mainfrom
triage/43647/40348362900-1

Conversation

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor

An uncommitted frame can wait indefinitely for an execution context after its page closes. Race context acquisition against the page's close scope and propagate target-closed errors without retrying or replacing them.

Extend the existing page-close promise-cancellation test with an unanswered iframe navigation. Verified on Linux across Chromium, Firefox and WebKit: 232 tests passed, 2 existing skips; the regression also passed in separate driver-process mode. An external DevTools target-close variant hangs without the fix and passes with it. Build and flint passed.

Fixes: #43647

Prepared by the triage workflow.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

if (this._page.delegate.noUtilityWorld?.())
world = 'main';
return this._contextData.get(world)!.contextPromise.then(contextOrDestroyedReason => {
return this._page.openScope.race(this._contextData.get(world)!.contextPromise.then(contextOrDestroyedReason => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the wrong place. Instead, when frame detaches, it should reject all contextPomise instances on itself. Similarly, when the page closes, it should detach all frames (including the main frame) and thus invalidate the context.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

microsoft-playwright-automation Bot added a commit that referenced this pull request Oct 27, 2026
#43650 (comment): Reuse frame-detach context invalidation for all frames on page disposal, preserve the close reason, and remove the context-acquisition race and its retry exception.
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🔴 The Firefox close-reason failure is caused by this PR

Hi, I'm the Playwright bot. I compared the failing test on the CI merge and its base: 5/5 repetitions failed with this PR; 5/5 passed without it.

Details

The latest merged report has one failed test and one flaky test. The Firefox failure is a regression in the revised frame-disposal change; the video flake is pre-existing.

Caused by this PR

  • [firefox-page] › page/expect-misc.spec.ts:679 › EX-243 should report page close reason when page closes during expect — the assertion error omits Bye bye. on all four CI attempts. The new dispose() call to _onDetached(error.message) closes frame/context waits with plain Errors. The detached frame stops retrying, but Frame.expect() only recognizes target/session-closed errors when reporting the close reason, so it drops that reason.

    On Linux with Firefox 158, the unchanged test failed all five repetitions, including every retry, on CI merge 124de408b289 (PR head 0b1a2e04b385). The same command on its base, c409f8c83ec0, passed all five: npm run test -- tests/page/expect-misc.spec.ts --project=firefox-page --grep EX-243 --workers=1 --repeat-each=5 --reporter=dot.

    The refreshed CI database does show the same missing-reason error outside this PR under tracing-firefox, including a failure then pass on main. That establishes an existing flake, but the controlled comparison above ties the repeatable standard-Firefox failure to this change.

Pre-existing flake / infra

  • [chromium-library] › library/video.spec.ts:762 › screencast › VI-030 should work with video+trace — passed on retry here. The same test, project, Linux bot, and Cannot read properties of undefined (reading 'file') error occur on unrelated main SHA c409f8c83ec0 in run 40425277344.

Two MCP jobs are still running; this verdict covers the reported failures and completed checks.

Triaged by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@dgozman Dmitry Gozman (dgozman) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now failing a test, please check.

Comment thread tests/library/page-close.spec.ts Outdated
if (contentOrError instanceof Error)
expect(contentOrError.message).toContain(kTargetClosedErrorMessage);
else
expect(contentOrError).toBe('<html><head></head><body></body></html>');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can this resolve with content? The iframe never loads, so this is very strange.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

microsoft-playwright-automation Bot added a commit that referenced this pull request Oct 29, 2026
#43650 (comment): Keep detaching all frames on page disposal and preserve the original error during context invalidation.
#43650 (review): Fix the reproduced Firefox EX-243 failure by preserving TargetClosedError so assertions report the custom page close reason.
#43650 (comment): Firefox can read the initial about:blank document before navigation commits; use a never-resolving iframe evaluation and require a target-closed error on every browser.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dgozman Dmitry Gozman (dgozman) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase now.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot. I started to address the review comments on Linux: agent run

#43650 (review): Rebased on 1d5572d; resolved the conflict by keeping detached-request cleanup on frame removal rather than page disposal, preserving page-close request errors.
#43650 (comment): Already addressed; retained frame detachment and context invalidation on page disposal.
#43650 (review): Retained original close errors; EX-243 and PA-051 pass across all three browsers after the rebase correction.
#43650 (comment): Already addressed; retained the pending iframe evaluation and required target-closed error.
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

5194 passed, 616 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

1 flaky ⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › VI-030 should work with video+trace `@chromium-playwright-x64-ubuntu24-64-core-node22`

23598 passed, 705 skipped


Merge workflow run.

@dgozman
Dmitry Gozman (dgozman) marked this pull request as ready for review October 30, 2026 16:12
@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit f0f066e into main Oct 30, 2026
24 checks passed
@pavelfeldman
Pavel Feldman (pavelfeldman) deleted the triage/43647/40348362900-1 branch October 30, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: frame.content() on a frame whose document never arrives hangs forever, even after the page is closed

2 participants