From f487a20b28ae83afdff2892852f26bb8c0e6bc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Tue, 3 Nov 2026 23:52:11 +0000 Subject: [PATCH] fix(cli): check waits for the composition as long as snapshot and render do (#6947) * test(cli): check waits as long as snapshot for the composition by default * fix(cli): check waits for the composition as long as snapshot and render do * docs(cli): check's --timeout default matches snapshot and render * fix(cli): check's render-ready warning advises a --timeout above the new default * fix(cli): drop the doc comment on the render-ready warning suffix * style(cli): format checkBrowser.ts --- docs/packages/cli.mdx | 2 +- packages/cli/src/commands/check.test.ts | 19 +++++++++++++++++++ packages/cli/src/commands/check.ts | 4 ++-- packages/cli/src/utils/checkBrowser.test.ts | 9 +++++++++ packages/cli/src/utils/checkBrowser.ts | 11 ++++++----- packages/cli/src/utils/checkPipeline.ts | 3 ++- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index 62d4315c28..96a803bb57 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -1211,7 +1211,7 @@ cover every finding from the full check. | `--max-issues` | Findings to print or return after static collapse (default 80) | | `--collapse-static` / `--no-collapse-static` | Fold a repeated static finding into one row (default: on) | | `--tolerance` | Allowed overflow in px before reporting (default 2) | -| `--timeout` | Render-ready budget in ms; also raises page navigation above its 10s floor (default 3000) | +| `--timeout` | Render-ready budget in ms; also raises page navigation above its 10s floor (default 45000, as snapshot and render) | | `--no-contrast` | Skip the WCAG pass while iterating | | `--strict` | Exit non-zero on warnings too (default: errors only) | | `--caption-zone ""` | Opt-in band gate. Flags a text element's DOM box that overlaps the fractional band. Optional `severity` and `seek`. | diff --git a/packages/cli/src/commands/check.test.ts b/packages/cli/src/commands/check.test.ts index d5b86b8af8..108f3f918b 100644 --- a/packages/cli/src/commands/check.test.ts +++ b/packages/cli/src/commands/check.test.ts @@ -4,6 +4,7 @@ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "nod import { tmpdir } from "node:os"; import { join } from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { DEFAULT_CONFIG } from "@hyperframes/engine"; const trackCheckReport = vi.fn(); vi.mock("../telemetry/events.js", () => ({ @@ -498,6 +499,24 @@ describe("skip contrast in motion", () => { }); }); +it("waits for the composition as long as snapshot and render do unless --timeout says otherwise", async () => { + const { report } = await runScenario(fakeDriver()); + const runPipeline = vi.fn(async (_project: ProjectDir, _options: CheckOptions) => report); + vi.spyOn(console, "log").mockImplementation(() => undefined); + const command = createCheckCommand({ + resolveProject: () => PROJECT, + runPipeline, + prepareMedia: vi.fn(async () => []), + withMeta: (value) => value, + }); + + await runCommand(command, { rawArgs: ["--json"] }); + await runCommand(command, { rawArgs: ["--json", "--timeout", "20s"] }); + + expect(runPipeline.mock.calls[0]?.[1].timeout).toBe(DEFAULT_CONFIG.playerReadyTimeout); + expect(runPipeline.mock.calls[1]?.[1].timeout).toBe(20_000); +}); + it("parses the caption-zone grammar and enables the frame gate", async () => { const { report } = await runScenario(fakeDriver()); const runPipeline = vi.fn(async (_project: ProjectDir, _options: CheckOptions) => report); diff --git a/packages/cli/src/commands/check.ts b/packages/cli/src/commands/check.ts index ac2026b343..cf299dd2c7 100644 --- a/packages/cli/src/commands/check.ts +++ b/packages/cli/src/commands/check.ts @@ -212,8 +212,8 @@ const CHECK_COMMAND_ARGS = { timeout: { type: "string", description: - "Initial render-ready timeout in ms, or with a unit (45s, 2m); also sets the navigation minimum (10s floor, default: 10000)", - default: "10000", + "Initial render-ready timeout in ms, or with a unit (45s, 2m); also sets the navigation minimum (10s floor, default: 45000, as snapshot and render)", + default: String(DEFAULT_CHECK_OPTIONS.timeout), }, contrast: { type: "boolean", diff --git a/packages/cli/src/utils/checkBrowser.test.ts b/packages/cli/src/utils/checkBrowser.test.ts index 9dcca61359..d9666ee260 100644 --- a/packages/cli/src/utils/checkBrowser.test.ts +++ b/packages/cli/src/utils/checkBrowser.test.ts @@ -1,6 +1,7 @@ // @vitest-environment happy-dom // fallow-ignore-file code-duplication import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { DEFAULT_CONFIG } from "@hyperframes/engine"; import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import os, { tmpdir } from "node:os"; import { join } from "node:path"; @@ -23,6 +24,7 @@ import { collectSeekClock, mergeHelperDrafts, samplingBrowserCount, + RENDER_READY_WARNING_SUFFIX, } from "./checkBrowser.js"; import { CheckDeadline } from "./checkDeadline.js"; import { closeManagedBrowser } from "../browser/launch.js"; @@ -2221,3 +2223,10 @@ describe("finding frame capture", () => { } }); }); + +describe("the render-ready warning's advice", () => { + it("names a --timeout above the default, so following it never lowers the wait", () => { + const example = /for example (\d+)s\)/.exec(RENDER_READY_WARNING_SUFFIX)?.[1]; + expect(Number(example) * 1000).toBeGreaterThan(DEFAULT_CONFIG.playerReadyTimeout); + }); +}); diff --git a/packages/cli/src/utils/checkBrowser.ts b/packages/cli/src/utils/checkBrowser.ts index 7b840a49f3..b959552b76 100644 --- a/packages/cli/src/utils/checkBrowser.ts +++ b/packages/cli/src/utils/checkBrowser.ts @@ -1,3 +1,4 @@ +import { DEFAULT_CONFIG } from "@hyperframes/engine"; import type { CheckDeadline } from "./checkDeadline.js"; import { SEEK_SETTLES_BEFORE_PROTOCOL_TIMEOUT_MS } from "../capture/captureTimeout.js"; import { logCheckProgress } from "./checkProgress.js"; @@ -92,6 +93,8 @@ import type { } from "./checkTypes.js"; import type { ProjectDir } from "./project.js"; +export const RENDER_READY_WARNING_SUFFIX = `the scene may still be building, so results can miss late content; raise --timeout (for example ${(DEFAULT_CONFIG.playerReadyTimeout * 2) / 1000}s)`; + interface RuntimeDraft { code: string; severity: CheckSeverity; @@ -195,7 +198,7 @@ function startCopyHeartbeat( /** * Awaits the H.264 authoring proxy for every browser-hostile local video * asset in `html` BEFORE the timed render-ready wait starts. `check`'s - * render-ready wait defaults to 3000ms (`DEFAULT_CHECK_OPTIONS.timeout`, + * render-ready wait defaults to 45 s (`DEFAULT_CHECK_OPTIONS.timeout`, * passed through as `renderReadyTimeoutMs`), and a cold `.transcode-cache` * cannot fit inside that window — without this, a project's first * hostile-asset check (e.g. a fresh CI checkout) would race the timeout @@ -381,8 +384,7 @@ export async function runBrowserCheck( const session = await openSettledCompositionPage(html, server.url, { navigationTimeoutMs: options.timeout, renderReadyTimeoutMs: options.timeout, - renderReadyWarningSuffix: - "the scene may still be building, so results can miss late content; raise --timeout (for example 20s)", + renderReadyWarningSuffix: RENDER_READY_WARNING_SUFFIX, prelaunched, browserGpuMode: options.browserGpuMode ?? resolveCliChromeGpuMode(), signal: deadline?.signal, @@ -538,8 +540,7 @@ async function openHelperSession( const session = await openSettledCompositionPage(html, url, { navigationTimeoutMs: options.timeout, renderReadyTimeoutMs: options.timeout, - renderReadyWarningSuffix: - "the scene may still be building, so results can miss late content; raise --timeout (for example 20s)", + renderReadyWarningSuffix: RENDER_READY_WARNING_SUFFIX, browserGpuMode: options.browserGpuMode ?? resolveCliChromeGpuMode(), signal: owner.signal, onBrowser: owner.onBrowser, diff --git a/packages/cli/src/utils/checkPipeline.ts b/packages/cli/src/utils/checkPipeline.ts index a7e78db712..a8acc8ad20 100644 --- a/packages/cli/src/utils/checkPipeline.ts +++ b/packages/cli/src/utils/checkPipeline.ts @@ -1,3 +1,4 @@ +import { DEFAULT_CONFIG } from "@hyperframes/engine"; import { BrowserCleanupError, onStopSignal } from "../browser/launch.js"; import type { CheckProgress } from "./checkProgress.js"; import { @@ -120,7 +121,7 @@ export const DEFAULT_CHECK_OPTIONS: CheckOptions = { maxIssues: 80, collapseStatic: true, tolerance: 2, - timeout: 10_000, + timeout: DEFAULT_CONFIG.playerReadyTimeout, contrast: true, strict: false, snapshots: false,