mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 14:50:02 +00:00
fix(encoder): signal host interruptions for retry (#3578)
* fix(encoder): signal host interruptions for retry * fix(encoder): cover all render interruption paths * fix(encoder): classify HDR pre-extraction drains
This commit is contained in:
@@ -2,7 +2,65 @@ import { EventEmitter } from "node:events";
|
||||
import { resolve } from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { formatFfmpegError } from "./runFfmpeg.js";
|
||||
import { formatFfmpegError, isExternalFfmpegInterruption } from "./runFfmpeg.js";
|
||||
|
||||
describe("isExternalFfmpegInterruption", () => {
|
||||
const base = {
|
||||
exitCode: 255,
|
||||
signal: null,
|
||||
stderr: "",
|
||||
terminationReason: "exit" as const,
|
||||
};
|
||||
|
||||
it("recognizes a direct external termination signal", () => {
|
||||
expect(isExternalFfmpegInterruption({ ...base, exitCode: null, signal: "SIGTERM" })).toBe(true);
|
||||
});
|
||||
|
||||
it("does not broaden the retry signal to SIGKILL", () => {
|
||||
expect(isExternalFfmpegInterruption({ ...base, exitCode: null, signal: "SIGKILL" })).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("recognizes ffmpeg's handled SIGTERM exit-255 signature", () => {
|
||||
expect(
|
||||
isExternalFfmpegInterruption({
|
||||
...base,
|
||||
stderr: "frame= 42\nExiting normally, received signal 15.\n",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not classify an ordinary exit 255", () => {
|
||||
expect(isExternalFfmpegInterruption({ ...base, stderr: "Encoder initialization failed" })).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("requires exit 255 when classification relies on ffmpeg stderr", () => {
|
||||
expect(
|
||||
isExternalFfmpegInterruption({
|
||||
...base,
|
||||
exitCode: 1,
|
||||
stderr: "Exiting normally, received signal 15.",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it.each(["abort", "deadline", "inactivity"] as const)(
|
||||
"keeps a managed %s termination non-retryable",
|
||||
(terminationReason) => {
|
||||
expect(
|
||||
isExternalFfmpegInterruption({
|
||||
...base,
|
||||
signal: "SIGTERM",
|
||||
stderr: "Exiting normally, received signal 15.",
|
||||
terminationReason,
|
||||
}),
|
||||
).toBe(false);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("formatFfmpegError", () => {
|
||||
const originalPlatform = process.platform;
|
||||
|
||||
Reference in New Issue
Block a user