From ff9c3b7619c6c46c3145b287914cd09b377174f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sat, 14 Nov 2026 10:28:28 +0000 Subject: [PATCH] fix(engine): an unrecognised capture failure is unknown, not the author's fault (#7730) * fix(engine): an unrecognised capture failure is unknown, not the author's fault * fix(engine): carry the extractor's disk-full words in a name, not a comment --- .../src/services/captureFailure.test.ts | 20 ++++++++++++++++--- .../engine/src/services/captureFailure.ts | 10 ++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/engine/src/services/captureFailure.test.ts b/packages/engine/src/services/captureFailure.test.ts index 3ffa9ad87d..730b135ffc 100644 --- a/packages/engine/src/services/captureFailure.test.ts +++ b/packages/engine/src/services/captureFailure.test.ts @@ -25,6 +25,17 @@ describe("classifyCaptureFailure", () => { ], // The timed-out variant of the same call stays protocol_timeout (checked first). ["Protocol error (Page.captureScreenshot): waiting for debugger timed out", "protocol_timeout"], + // A full disk and a struggling browser are the host's failure, never the composition's. + ["The disk filled up while video frames were extracted", "io"], + [ + "[Parallel] Capture failed: Worker 0: net::ERR_INSUFFICIENT_RESOURCES at http://localhost:63145/index.html", + "transient_browser", + ], + [ + "[FrameCapture] window.__hf not ready after 45000ms. Page must expose window.__hf = { duration, seek }.\nState: __hf=true, seek=true, player=true, renderReady=true, duration=241.5", + "transient_browser", + ], + ["something no rule names", "unknown"], ] as const)("classifies %s as %s", (message, kind) => { expect(classifyCaptureFailure(new Error(message)).kind).toBe(kind); }); @@ -81,21 +92,24 @@ describe("classifyCaptureFailure", () => { // the message alone must still classify. expect(classifyCaptureFailure(new Error(`[Parallel] write ${code}`)).kind).toBe("io"); } - expect(classifyCaptureFailure(new Error("write to EPIPEline")).kind).toBe("authoring"); + expect(classifyCaptureFailure(new Error("write to EPIPEline")).kind).toBe("unknown"); }); it("classifies repeated operation text in linear time", () => { const repeatedCopy = "copy".repeat(25_000); - expect(classifyCaptureFailure(new Error(repeatedCopy)).kind).toBe("authoring"); + expect(classifyCaptureFailure(new Error(repeatedCopy)).kind).toBe("unknown"); expect(classifyCaptureFailure(new Error(`${repeatedCopy} failed`)).kind).toBe("io"); - expect(classifyCaptureFailure(new Error("copy\nfailed")).kind).toBe("authoring"); + expect(classifyCaptureFailure(new Error("copy\nfailed")).kind).toBe("unknown"); }); it("marks structural failures fatal but leaves retryable failures non-fatal", () => { expect( isFatalCaptureFailure(new CaptureFailure({ kind: "authoring", message: "bad source" })), ).toBe(true); + expect( + isFatalCaptureFailure(new CaptureFailure({ kind: "unknown", message: "unnamed failure" })), + ).toBe(true); expect( isFatalCaptureFailure( new CaptureFailure({ kind: "protocol_timeout", message: "protocol timeout" }), diff --git a/packages/engine/src/services/captureFailure.ts b/packages/engine/src/services/captureFailure.ts index 5c19250b2d..f4309fd219 100644 --- a/packages/engine/src/services/captureFailure.ts +++ b/packages/engine/src/services/captureFailure.ts @@ -5,7 +5,8 @@ export type CaptureFailureKind = | "memory_exhaustion" | "verification" | "authoring" - | "io"; + | "io" + | "unknown"; export interface CaptureWorkerDiagnostic { workerId: number; @@ -56,6 +57,8 @@ const TRANSIENT_BROWSER_ERROR_PATTERNS = [ /net::ERR_NETWORK_CHANGED/i, /Composition has zero duration[\s\S]*Runtime ready: false/, /Composition setup did not finish/, + /window\.__hf not ready after \d+ms/, + /net::ERR_INSUFFICIENT_RESOURCES/, // CDP can refuse a capture call outright with this exact wording; timed-out // variants of the same call hit PROTOCOL_TIMEOUT_PATTERNS, checked first. // Anchored to this literal reason (not just the CDP method) so an unrelated, @@ -137,6 +140,8 @@ function hasIoOperationFailure(message: string): boolean { */ const BROKEN_PIPE_MESSAGE = /\bwrite (?:EPIPE|EOF|ECONNRESET)\b/; +const EXTRACTOR_DISK_FULL_WORDS = /The disk filled up/i; + function ioError(error: unknown, message: string): boolean { const code = error instanceof Error ? (error as NodeJS.ErrnoException).code : undefined; return ( @@ -147,6 +152,7 @@ function ioError(error: unknown, message: string): boolean { ), ) || BROKEN_PIPE_MESSAGE.test(message) || + EXTRACTOR_DISK_FULL_WORDS.test(message) || hasIoOperationFailure(message) ); } @@ -176,7 +182,7 @@ function classifyKind( } const rule = ORDERED_KIND_RULES.find(([, matches]) => matches(message)); if (rule) return rule[0]; - return ioError(error, message) ? "io" : "authoring"; + return ioError(error, message) ? "io" : "unknown"; } export function classifyCaptureFailure(