diff --git a/packages/producer/src/verifyStaticPage.ts b/packages/producer/src/verifyStaticPage.ts index 3fa65e473b..4c3c80735d 100644 --- a/packages/producer/src/verifyStaticPage.ts +++ b/packages/producer/src/verifyStaticPage.ts @@ -37,7 +37,13 @@ export async function checkPageLoads( failures.push(`pageerror: ${err instanceof Error ? err.message : String(err)}`); }); page.on("console", (msg) => { - if (msg.type() === "error") failures.push(`console.error: ${msg.text()}`); + if (msg.type() !== "error") return; + const failedResourceUrl = msg.text().startsWith("Failed to load resource") + ? msg.location().url + : ""; + failures.push( + `console.error: ${msg.text()}${failedResourceUrl ? ` (${failedResourceUrl})` : ""}`, + ); }); try { await page.goto(originUrl, { waitUntil: "domcontentloaded" }); diff --git a/scripts/verify-catalog-payloads.test.ts b/scripts/verify-catalog-payloads.test.ts index 73de6f90e8..4615a47185 100644 --- a/scripts/verify-catalog-payloads.test.ts +++ b/scripts/verify-catalog-payloads.test.ts @@ -9,6 +9,7 @@ import { declaresWebgpu, itemsFromDiff, withoutAbortedMedia, + withoutMissingCaptionOverrides, parsePayload, remainingFailures, withoutWebgpuAbsence, @@ -94,6 +95,26 @@ describe("withoutAbortedMedia", () => { }); }); +describe("withoutMissingCaptionOverrides", () => { + it("drops the runtime's missing caption-overrides.json and keeps every other failure", () => { + const url = "http://localhost:4000/caption-overrides.json"; + const miss = [ + `404 GET ${url}`, + `console.error: Failed to load resource: the server responded with a status of 404 (Not Found) (${url})`, + `request failed: ${url} (net::ERR_ABORTED)`, + ]; + const kept = [ + `500 GET ${url}`, + `request failed: ${url} (net::ERR_NAME_NOT_RESOLVED)`, + "404 GET http://localhost:4000/public/catalog/caption-overrides.json.png", + "404 GET http://localhost:4000/assets/caption-overrides.json", + "console.error: Failed to load resource: the server responded with a status of 404 (Not Found) (http://localhost:4000/x.png)", + "console.error: [HyperFrames] Invalid caption-overrides.json: expected an array", + ]; + assert.deepEqual(withoutMissingCaptionOverrides([...miss, ...kept]), kept); + }); +}); + it("browser selection includes regenerated edits and new untracked payloads", (t) => { const root = mkdtempSync(join(tmpdir(), "catalog-selection-")); t.after(() => rmSync(root, { recursive: true, force: true })); diff --git a/scripts/verify-catalog-payloads.ts b/scripts/verify-catalog-payloads.ts index b194799432..42ce1d5747 100644 --- a/scripts/verify-catalog-payloads.ts +++ b/scripts/verify-catalog-payloads.ts @@ -96,7 +96,36 @@ export function withoutWebgpuAbsence(webgpu: boolean, failures: string[]): strin /** What still counts as a failure for one item once the environment's own noise is set aside. */ export function remainingFailures(kindDir: string, item: string, failures: string[]): string[] { - return withoutAbortedMedia(withoutWebgpuAbsence(declaresWebgpu(kindDir, item), failures)); + return withoutMissingCaptionOverrides( + withoutAbortedMedia(withoutWebgpuAbsence(declaresWebgpu(kindDir, item), failures)), + ); +} + +const CAPTION_OVERRIDES_MISS = [ + /^404 GET (\S+)$/, + /^request failed: (\S+) \(net::ERR_ABORTED\)$/, + /^console\.error: Failed to load resource: the server responded with a status of 404 \(Not Found\) \((\S+)\)$/, +]; + +function isCaptionOverridesUrl(url: string): boolean { + try { + return new URL(url).pathname === "/caption-overrides.json"; + } catch { + return false; + } +} + +/** The runtime asks for an optional caption-overrides.json on any page with a .caption-group and + * reads a 404 as "no overrides"; the docs host has none. `hyperframes validate` passes the same + * miss (shouldIgnoreHttpError). Any other status, or an invalid file, still counts. */ +export function withoutMissingCaptionOverrides(failures: string[]): string[] { + return failures.filter( + (failure) => + !CAPTION_OVERRIDES_MISS.some((pattern) => { + const url = pattern.exec(failure)?.[1]; + return url !== undefined && isCaptionOverridesUrl(url); + }), + ); } export type Payload = { kind: "live"; html: string } | { kind: "marker"; reason: string };