fix(producer): narrow extraction error shapes honestly

This commit is contained in:
James
2026-07-26 19:47:33 +00:00
parent 9b63646c8a
commit c01e1a5f96
3 changed files with 11 additions and 11 deletions
@@ -198,8 +198,8 @@ export function isVideoSourceExtractionError(error: unknown): error is VideoSour
return (
typeof error === "object" &&
error !== null &&
(error as { hyperframesVideoSourceExtractionError?: unknown })
.hyperframesVideoSourceExtractionError === true
"hyperframesVideoSourceExtractionError" in error &&
error.hyperframesVideoSourceExtractionError === true
);
}
+4 -7
View File
@@ -118,10 +118,10 @@ interface PreparedRenderInput {
}
const DEFAULT_SERVER_FPS = { num: 30, den: 1 } as const;
const SAFE_RENDER_ERROR_CODES = new Set([
const SAFE_RENDER_ERROR_CODES = new Set<string>([
"VIDEO_SOURCE_UNRENDERABLE",
"VIDEO_EXTRACTION_FAILED",
] as const);
]);
/**
* Preserve only bounded producer error codes across JSON/SSE. Never derive a
@@ -129,11 +129,8 @@ const SAFE_RENDER_ERROR_CODES = new Set([
*/
export function extractSafeRenderErrorCode(error: unknown): string | undefined {
if (typeof error !== "object" || error === null || !("code" in error)) return undefined;
const code = (error as { code?: unknown }).code;
return typeof code === "string" &&
SAFE_RENDER_ERROR_CODES.has(code as "VIDEO_SOURCE_UNRENDERABLE" | "VIDEO_EXTRACTION_FAILED")
? code
: undefined;
const code = error.code;
return typeof code === "string" && SAFE_RENDER_ERROR_CODES.has(code) ? code : undefined;
}
function parseServerFps(value: unknown): RenderInput["fps"] {
@@ -193,8 +193,11 @@ describe("assertVideoExtractionSucceeded", () => {
{ kind: "zero_output", count: 1 },
],
});
expect((caught as Error).message).not.toContain("/tmp/");
expect((caught as Error).message).not.toContain("Signature");
if (!(caught instanceof Error)) {
throw new Error("expected VideoExtractionStageError");
}
expect(caught.message).not.toContain("/tmp/");
expect(caught.message).not.toContain("Signature");
});
it("keeps exhausted transient failures retryable and collapses duplicate kinds", () => {