Skip to content

fix(cli): validate navigation timeout honors --timeout, hints on CDN scripts#1929

Draft
miguel-heygen wants to merge 1 commit into
mainfrom
fix/validate-nav-timeout-honors-flag
Draft

fix(cli): validate navigation timeout honors --timeout, hints on CDN scripts#1929
miguel-heygen wants to merge 1 commit into
mainfrom
fix/validate-nav-timeout-honors-flag

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Root cause

validate navigated the page with a hardcoded 10s timeout (page.goto(..., { timeout: 10000 })) that ignored the --timeout option. A composition that loads GSAP (or any library) from a CDN <script> in <head> blocks domcontentloaded until that script finishes downloading; on a slow network that exceeds 10s and validate fails with an opaque "Navigation timeout of 10000ms exceeded" — even though:

  • the full render (much larger budget) rides it out fine, so the composition is actually valid, and
  • --timeout (the documented "wait longer for slow loads" knob) had no effect on navigation, so the only recourse was to change the composition (vendor the script locally).

Reported precisely, with the exact error and the observation that render's 60s budget masks it while validate's 10s trips.

Fix

  • resolveNavigationTimeoutMs(optTimeout) = max(10s floor, --timeout), so --timeout now also extends the navigation budget. Default behavior is unchanged: the default --timeout (3000) stays clamped to the 10s floor, and compositions that navigate within 10s are unaffected.
  • navigationTimeoutHint() replaces Puppeteer's opaque timeout error with an actionable message naming the likely cause (a blocking CDN <script>) and the two fixes (vendor locally / raise --timeout). Any non-timeout error is rethrown unchanged.
  • --timeout help text updated to note it also governs navigation.

Both helpers are pure and exported; validateInBrowser wires them around the single page.goto.

Test plan

  • resolveNavigationTimeoutMs: floor kept for unset / default-3000 / zero; raised to --timeout when it exceeds the floor.
  • navigationTimeoutHint: rewrites a nav-timeout error with CDN + --timeout guidance; returns null for other errors so the caller rethrows them as-is.
  • bunx vitest run packages/cli/src/commands/validate.test.ts — 14/14 passing (was 9).
  • CLI tsc --noEmit clean; full bun run build clean; oxlint/oxfmt clean.

…scripts

`validate` navigated the page with a hardcoded 10s timeout that ignored
the --timeout option. A composition that loads GSAP (or any library)
from a CDN <script> in <head> blocks `domcontentloaded` until that
script finishes downloading; on a slow network that exceeds 10s and
validate fails with an opaque "Navigation timeout of 10000ms exceeded"
— even though the full render (much larger budget) rides it out fine,
and even though --timeout (the documented "wait longer for slow loads"
knob) had no effect on navigation. The only recourse was to change the
composition (vendor the script locally).

Reported precisely, with the exact error and the observation that
render's 60s budget masks it while validate's 10s trips.

Fix:
- resolveNavigationTimeoutMs(optTimeout) = max(10s floor, --timeout), so
  --timeout now also extends the navigation budget. Default behavior is
  unchanged: the default --timeout (3000) stays clamped to the 10s floor.
- navigationTimeoutHint() replaces Puppeteer's opaque timeout error with
  an actionable message naming the likely cause (a blocking CDN <script>)
  and the two fixes (vendor locally / raise --timeout). Any non-timeout
  error is rethrown unchanged.
- --timeout help text updated to note it also governs navigation.

Both helpers are pure and exported; validateInBrowser wires them around
the single page.goto. No behavior change for compositions that navigate
within 10s.

Test: resolveNavigationTimeoutMs (floor kept for unset/small/zero,
raised past the floor) and navigationTimeoutHint (rewrites a nav-timeout
error with CDN + --timeout guidance; returns null for other errors so
the caller rethrows as-is). validate suite 14 tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant