Repository navigation
Conversation
🦋 Changeset detectedLatest commit: a0d54c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
2 tasks done
…ts context A wait issued right after the action that triggers a navigation is pinned to the outgoing document. When the navigation commits, Chrome rejects the awaited wait with "Inspected target navigated or closed" or "Execution context was destroyed", which waitInLocatorWorld did not recognize as context loss, so the wait failed instead of being re-issued in the new document. Treat both messages like "Cannot find context with specified id" in the existing single retry.
arrufat
force-pushed
the
fix/wait-for-selector-across-navigation
branch
from
October 19, 2026 10:30
a0d54c6 to
7d2f75e
Compare
Author
|
Could a maintainer approve the latest commit so CI can run? The previous runs expired waiting for approval. |
This branch has not been deployed
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 #2982.
Why
page.waitForSelector()is typically issued right after thelocator.click()that submits a form, so its wait is installed in the document about to be navigated away from. When the commit lands whileFrame.waitInLocatorWorldis awaiting the wait handle, Chrome rejects theRuntime.callFunctionOnwith-32000 Inspected target navigated or closed(V8 words itExecution context was destroyed). The existing context-loss retry only recognizesCannot find context with specified id, so the wait failed instead of being re-issued in the new document.With a local form target that answers after 100 ms this fails deterministically on Chrome 153; with a fast target it fails about 2 runs in 5. The standalone repro is in #2982.
What changed
packages/extension/understudy/frame.ts:waitInLocatorWorldtreats both navigation-teardown messages as context loss, alongsideCannot find context with specified id. They go through the existing single retry, so the re-issued wait gets a fresh locator world and the time left on the sharedProgressdeadline. Anything else, a second loss, or an expired deadline still throw as before.The retry stays scoped to the selector wait, which has no side effects.
Frame.evaluateis unchanged, since replaying an arbitrary evaluate after it ran can duplicate side effects (#2751).packages/extension/understudy/waitForSelector.test.ts: the awaited wait is rejected once with each teardown message; the wait is re-installed in the new locator context and resolves.Rebased onto #3146, which moved selector waits to
waitInLocatorWorld; the earlier version of this PR added a retry loop inPage.waitForSelector, which is no longer needed.