Repository navigation
fix: bound navigation wait in waitForEventsAfterAction to the timeout - #3226
rudycelekli wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@rudycelekli please sign the CLA |
OrKoN
left a comment
There was a problem hiding this comment.
marking as needing changes
|
Rebased onto current main. The conflict in The Google CLA check is still the open review. I can't sign that from here. |
Part of ChromeDevTools#3394 `WaitForHelper` decides whether an action navigated by comparing the page URL before and after it. So a load that ends on the same URL, like a reload or a form POST that redirects back, isn't reported at all. This now also tracks whether the main frame loaded a new document during the action: CDP reports each one with `Page.frameNavigated`, while same-document navigations come as `Page.navigatedWithinDocument`. A new document then gets the existing `Page navigated to <url>.` line and `structuredContent.navigatedToUrl` even when its URL didn't change, in every tool that reports navigations: `click`, `click_at`, `drag`, `fill`, `fill_form`, `hover`, `press_key`, `type_text` and `evaluate_script`. I checked the tracking against whether `performance.timeOrigin` changed in headless Chrome 156, and it matched in all 15 cases I tried, among them a form POST redirecting back to the same URL, a cross-origin navigation, one committing after the 100 ms window and back/forward cache restores. The new test covers a reload that keeps the URL and fails on `main`. Another one, a `replaceState` that keeps the URL, passes on `main` too but fails if same-document navigations count as new documents. `npm run test` passes locally (macOS, Node 26, Chrome 156), and so does the suite after `npm run bundle`. `PageCollector` still pairs `FrameNavigatedWithinDocument` with `framenavigated` in two places, so I'm happy to move both, and the tracking here, onto the events from puppeteer/puppeteer#15759 once they land. How same-document navigations are reported moved to ChromeDevTools#3410, which builds on this. ChromeDevTools#3226 also touches `WaitForHelper.ts`, so I can rebase on it if it lands first.
|
@rudycelekli this still needs a signed CL and another rebase. PTAL |
When a navigation did not complete, navigate_page returned long after its timeout: the action already waited for the timeout inside goto, the helper then waited for the same navigation for another full timeout, and finally waited up to 3s for a stable DOM on a page that never settled. Only wait for the remaining part of the timeout budget and skip the stable DOM wait when the navigation timed out. Fixes ChromeDevTools#2943 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ff2661c to
edc6b51
Compare
|
Rebased onto Fresh GN-based checks remain unverified: dependency sync was stopped at the workspace's free-disk reserve, leaving the GN binary/generated configs unavailable. I labelled the earlier test results as prior-revision evidence in the description and recorded the current limitation. The Google CLA check still requires contributor action. |
|
@rudycelekli |
|
@OrKoN, friendly reminder: this PR has new commits since the last review and has been waiting for 7 day(s) (automated reminder) |
Fixes #2943
Root cause
This is in this repo (
WaitForHelper.waitForEventsAfterAction), not in Puppeteer.navigate_pagerunsgoto(url, {timeout})inside the helper's action and catches its timeout error. Afterwards the helper:options.timeout(or 3 s when unset), and#stableDomTimeout) for a stable DOM on a page that never finished navigating.So a hanging server cost about
2 * timeout + 3 s.Fix
expectNavigationIn, to avoid racing a navigation that just finished).Actions that return quickly (click, etc.) behave as before.
Original verification (prior revision)
navigate_page returns close to the timeout when the server never responds(real Chrome, server that never responds,timeout: 1000): failed before the fix (about 5.0 s), passes after.npm run test tests/tools/pages.test.ts tests/utils/WaitForHelper.test.ts,npm run typecheck,npm run check-format: pass.npm run test: all pass exceptcaptures logs and errors from extension service worker(tests/tools/console.test.ts), which hit a "Target closed" error under full-suite load; it passes when run alone, both onmainand with this change.npm run gennot run: no tool descriptions or schemas changed.Current revision verification (2026-11-19)
Rebased onto
bdecb63549a0b1a6d073fdf69ecc264bf46adda9; current head isedc6b51420a20efeb44ff5bd8218abe7086cd946. The test import conflict preserves main's current mocks andgetTextContenthelper alongside this change'sserverHooksimport. The production patch has the same stable patch ID as the prior revision, and the navigation-timeout regression body is unchanged.git diff --checkpasses.Fresh local functional validation is blocked by build setup: the current GN/Ninja dependency sync approached the workspace's minimum free-disk reserve and was stopped. The GN executable and generated TypeScript configs are unavailable. The attempted
npm run typecheck, focused and fullnpm run test,npm run format, andnpm run check-formattherefore could not complete. No fresh test or formatting pass is claimed for this rebased revision; the results above belong to the prior revision.The Google CLA check remains outstanding and requires the contributor's legal agreement.