fix(cli): the FFmpeg cannot-start error names the OS error code or signal (#7115)

* fix(cli): the FFmpeg cannot-start error names the OS error code or signal

* fix(cli): drop a comment the check counts

* test(cli): a timed-out FFmpeg reads as the timeout, not its kill signal
This commit is contained in:
Miguel Ángel
2026-11-03 23:29:40 +00:00
committed by GitHub
parent 87a42e7470
commit 482bcd73ed
2 changed files with 33 additions and 3 deletions
@@ -170,6 +170,24 @@ describe("runEnvironmentChecks", () => {
expect(result.ffmpegPath).toBeUndefined();
});
it.each([
{ error: { code: "ENOENT" }, said: "(ENOENT)" },
{ error: { code: "EACCES" }, said: "(EACCES)" },
{ error: { signal: "SIGKILL" }, said: "(signal SIGKILL)" },
{ error: { code: "ETIMEDOUT", signal: "SIGTERM" }, said: "(ETIMEDOUT)" },
])("names how FFmpeg failed to start: $said", async ({ error, said }) => {
runProcess.mockImplementation((binaryPath: string) => {
if (binaryPath !== process.env.HYPERFRAMES_FFMPEG_PATH)
return Promise.resolve({ stdout: "ffprobe version 7.1.1\n", stderr: "" });
throw Object.assign(new Error("spawn failed"), error);
});
const result = await runEnvironmentChecks();
const ffmpeg = result.outcomes.find((outcome) => outcome.name === "FFmpeg");
expect(ffmpeg?.detail).toBe(`Failed to run "${process.execPath}" -version ${said}.`);
});
// Windows DLL advice only on Windows; elsewhere the platform install hint.
describe("FFmpeg cannot-start hint is platform-specific", () => {
const realPlatform = process.platform;
+15 -3
View File
@@ -95,9 +95,21 @@ async function readToolVersion(
};
} catch (error) {
if (signal?.aborted) signal.throwIfAborted();
const status =
typeof error === "object" && error !== null && "status" in error ? error.status : undefined;
const exitDetail = typeof status === "number" ? ` (exit code ${status})` : "";
const field = (name: string) =>
typeof error === "object" && error !== null && name in error
? (error as Record<string, unknown>)[name]
: undefined;
const status = field("status");
const code = field("code");
const killedBy = field("signal");
const exitDetail =
typeof status === "number"
? ` (exit code ${status})`
: typeof code === "string"
? ` (${code})`
: typeof killedBy === "string"
? ` (signal ${killedBy})`
: "";
return {
ok: false,
detail: `Failed to run "${binaryPath}" -version${exitDetail}.`,