fix(core): bound the domcontentloaded wait in ensureOptimizedPageLoad#517
Merged
Conversation
waitForLoadState("domcontentloaded") was called with no timeout, while the
"load" wait right below it is bounded by actionTimeoutMs. A navigation that
commits to a page (or SPA soft-navigation) that never fires DOMContentLoaded as
Playwright tracks it could hang this await indefinitely — the same class of
freeze fixed in #511, on the path that runs after every navigation.
Pass { timeout: this.actionTimeoutMs } to the domcontentloaded wait. It is
already wrapped in a try/catch that continues on failure, so a timeout simply
proceeds to the bounded "load" wait and the settle delay; no behavior change on
healthy pages.
Closes #514
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents PlaywrightBrowser.ensureOptimizedPageLoad() from hanging indefinitely by bounding the waitForLoadState("domcontentloaded") call with the existing actionTimeoutMs, aligning it with the already-bounded "load" wait and preserving current behavior on healthy pages.
Changes:
- Add
{ timeout: this.actionTimeoutMs }topage.waitForLoadState("domcontentloaded")insideensureOptimizedPageLoad. - Add a unit test ensuring the
domcontentloadedwait is invoked with the timeout (regression guard).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/browser/playwrightBrowser.ts | Bounds the domcontentloaded load-state wait with actionTimeoutMs to avoid unbounded hangs. |
| packages/core/test/playwrightBrowser.test.ts | Adds a regression test asserting the domcontentloaded wait includes the timeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #514.
Problem
PlaywrightBrowser.ensureOptimizedPageLoad()waited fordomcontentloadedwith no timeout:The
loadwait immediately below is bounded byactionTimeoutMs, and the settle is a fixed 1s — only this first wait was unbounded. A navigation that commits to a page (or SPA soft-navigation) that never firesDOMContentLoadedas Playwright tracks it could hang the await indefinitely. Same class of freeze as #511, on the path that runs after every navigation (click-nav,goto, back/forward).Fix
Pass
{ timeout: this.actionTimeoutMs }to thedomcontentloadedwait, matching theloadwait. It's already inside atry/catchthat continues on failure, so a timeout simply proceeds to the boundedloadwait and the settle delay — no behavior change on healthy pages, just removes the unbounded-hang risk. ReusesactionTimeoutMsrather than adding a new knob (both waits answer "how long to wait for the page to be ready").Testing
ensureOptimizedPageLoadtest assertingwaitForLoadState("domcontentloaded", { timeout: actionTimeoutMs })is called (guards against the timeout being dropped again). Red before the fix, green after.prettier --checkclean.No live run: this is a latent path (needs a page that never fires
DOMContentLoaded), not reliably reproducible on demand; the unit test is the meaningful guard and the change mirrors the already-boundedloadwait.Context
Follow-up to #511. Sibling reliability issues: #515 (stream timeout), #516 (agent-loop watchdog).
🤖 Generated with Claude Code