Repository navigation
fix(chromium): re-issue Target.closeTarget when the target survives a racing navigation commit - #42367
Closed
Jeff Witt (wittjeff) wants to merge 1 commit into
Closed
fix(chromium): re-issue Target.closeTarget when the target survives a racing navigation commit#42367Jeff Witt (wittjeff) wants to merge 1 commit into
Jeff Witt (wittjeff) wants to merge 1 commit into
Conversation
… racing navigation commit Chromium can acknowledge Target.closeTarget with success:true without actually closing the target: when the close races a navigation commit that swaps the main RenderFrameHost, the pending close request dies with the old frame host and the target never detaches, so page.close() hangs forever (https://issues.chromium.org/issues/536385539). Wait briefly for the page to close after Target.closeTarget and re-issue the close if the target is still alive. Also remove the stale fixme from the close-during-reload test: the rolled Chromium 152.0.7977.54 no longer loses the close in that scenario, and with the re-issue guard the close is robust either way. The guard chiefly protects channel builds (Chrome/Edge stable are on 151-class builds where the hang reproduces on ~70-80% of attempts with a meta-refresh trigger). Fixes microsoft#42068. References microsoft#42366. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 22, 2026
Author
|
@microsoft-github-policy-service agree [company="YRA Tech"] |
Author
|
@microsoft-github-policy-service agree company="YRA Tech" |
Contributor
|
please see #41912 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #42068. References #42366 and https://issues.chromium.org/issues/536385539.
The bug
Chromium can acknowledge
Target.closeTargetwithsuccess:truewithout actually closing the target: when the close races a navigation commit that swaps the main RenderFrameHost, the pending close request dies with the old frame host and is never re-issued (root-caused with code pointers in the crbug, which has a pending Chromium CL).Target.targetDestroyednever fires, sopage.close()awaitsclosedPromiseforever — no resolution, no rejection.The fix
In
CRBrowser._closePage, wait briefly (1 s) for the page to report closed afterTarget.closeTarget, and re-issue the close if the target is still alive (bounded at 3 attempts). Re-issuing reliably destroys such a target — verified over raw CDP as well as through Playwright. The normal path is unchanged: the close event resolves the wait immediately.Why a client-side guard when a Chromium CL is pending
channel: 'chrome'/'msedge'users are on 151-class stable builds where the hang reproduces on 7–8 of 10 attempts with a common real-world trigger — a page carrying<meta http-equiv="refresh" content="0; URL=...">closed right after the refresh commits (the W3C ACT-Rules bc659a "passed" fixtures are examples; we hit this scanning real pages, freezing long crawls for 35+ minutes with no error anywhere).closeTarget→success:true, notargetDestroyed, target still inTarget.getTargets) reproduces ~2/10 on 152 vs ~1-3/10 on 151. What changed in 152 is timing — through Playwright's call sequence the window has become hard to hit (0/10 in our runs), which is why no new test accompanies this PR: a race test that cannot reliably fail without the fix on the bundled browser would only be flaky. On 151-class builds the hang was near-deterministic through Playwright.Test changes
fixmefromshould close page while a reload is committing: it passes 6/6 repeats on the bundled 152 both with and without this change (the reload trigger no longer loses the close there), and with the guard it is robust on 151-class builds too, where it previously hung.tests/library/page-close.spec.ts,beforeunload.spec.ts, andbrowsercontext-pages.spec.tspass with the change (41/41).Verification matrix (10 rounds per cell, meta-refresh repro)
close()close({runBeforeUnload:true})context.close()🤖 Generated with Claude Code