mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix(producer): narrow extraction error shapes honestly
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user