mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 22:58:02 +00:00
The render pre-flight check shells out to `which ffmpeg`, which only searches the server process's PATH. When Studio is launched from a GUI/Dock/launchd context that PATH lacks /opt/homebrew/bin, so `which` fails even when ffmpeg is installed — and POST /render returns 503 "FFmpeg not found". Fall back to probing well-known install dirs (Homebrew on Apple Silicon and Intel, plus system/Linux locations) when the PATH lookup fails. Also drop the [kf:static]/[kf:runtime] keyframe diagnostics that were spamming the Studio console in prod, and fix two unrelated CI breakages the branch inherited: a Windows-sensitive ffmpeg test (pin platform) and a stale player test mock missing onRuntimeReady.
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { execSync } from "node:child_process";
|
|
import { existsSync } from "node:fs";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("node:child_process", () => ({ execSync: vi.fn() }));
|
|
vi.mock("node:fs", () => ({ existsSync: vi.fn() }));
|
|
|
|
const mockExec = vi.mocked(execSync);
|
|
const mockExists = vi.mocked(existsSync);
|
|
|
|
// The common-dir fallback list is platform-gated (empty on win32), so pin the
|
|
// platform to a POSIX value to keep the test deterministic on Windows CI.
|
|
const originalPlatform = process.platform;
|
|
beforeEach(() => {
|
|
Object.defineProperty(process, "platform", { value: "linux", configurable: true });
|
|
vi.resetModules();
|
|
});
|
|
|
|
afterEach(() => {
|
|
Object.defineProperty(process, "platform", { value: originalPlatform, configurable: true });
|
|
vi.clearAllMocks();
|
|
delete process.env.HYPERFRAMES_FFMPEG_PATH;
|
|
});
|
|
|
|
describe("findFFmpeg", () => {
|
|
it("falls back to a common install dir when `which` fails (GUI-launched PATH)", async () => {
|
|
// Simulate a process whose PATH lacks /opt/homebrew/bin: `which ffmpeg` throws.
|
|
mockExec.mockImplementation(() => {
|
|
throw new Error("which: no ffmpeg in PATH");
|
|
});
|
|
mockExists.mockImplementation((p) => p === "/opt/homebrew/bin/ffmpeg");
|
|
|
|
const { findFFmpeg } = await import("./ffmpeg.js");
|
|
expect(findFFmpeg()).toBe("/opt/homebrew/bin/ffmpeg");
|
|
});
|
|
|
|
it("returns undefined when ffmpeg is on neither PATH nor a common dir", async () => {
|
|
mockExec.mockImplementation(() => {
|
|
throw new Error("not found");
|
|
});
|
|
mockExists.mockReturnValue(false);
|
|
|
|
const { findFFmpeg } = await import("./ffmpeg.js");
|
|
expect(findFFmpeg()).toBeUndefined();
|
|
});
|
|
});
|