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
This commit is contained in:
Miguel Ángel
2026-11-14 10:28:28 +00:00
committed by GitHub
parent fe8d93056c
commit ff9c3b7619
2 changed files with 25 additions and 5 deletions
@@ -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" }),
@@ -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(