mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-04 07:19:52 +00:00
fix(cli): detect missing Chrome libs & ffmpeg on Linux/WSL in doctor (#1841)
WSL first-render success (34.7%) is dominated by a downloaded chrome-headless-shell that launches into `libnss3.so: cannot open shared object file` — doctor/preflight only checked the binary exists, never that it can load its libraries. - New linuxDeps.ts: /etc/os-release distro detection (Debian/Fedora/Arch/Alpine) + WSL detection, per-distro Chrome dep set, ldd-based shared-lib probe. - preflight.checkChrome downgrades a found-but-unlaunchable Chrome to a render-blocking error with the exact per-distro install command. - Distro-aware ffmpeg hints; launch failures converted to actionable guidance pointing at `hyperframes doctor` (skipped on ARM64). - Detect + print remediation (no auto-install). Render-reliability workstream P1-4. Success measured on PostHog dashboard 1783183. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1d4c5d5ec3
commit
180f368af1
@@ -2,6 +2,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { parseToolVersion, runEnvironmentChecks } from "./preflight.js";
|
||||
import * as manager from "./manager.js";
|
||||
import * as linuxDeps from "./linuxDeps.js";
|
||||
|
||||
describe("runEnvironmentChecks", () => {
|
||||
const originalFfmpegPath = process.env.HYPERFRAMES_FFMPEG_PATH;
|
||||
@@ -102,6 +103,83 @@ describe("runEnvironmentChecks", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("runEnvironmentChecks — Chrome shared libraries (Linux/WSL)", () => {
|
||||
const originalPlatform = process.platform;
|
||||
|
||||
beforeEach(() => {
|
||||
Object.defineProperty(process, "platform", { value: "linux", configurable: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Object.defineProperty(process, "platform", { value: originalPlatform, configurable: true });
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("downgrades a found Chrome to a render-blocking error when libs are missing", async () => {
|
||||
vi.spyOn(manager, "findBrowser").mockResolvedValue({
|
||||
executablePath: "/root/.cache/hyperframes/chrome-headless-shell",
|
||||
source: "cache",
|
||||
});
|
||||
vi.spyOn(linuxDeps, "probeChromeSharedLibs").mockReturnValue({
|
||||
ok: false,
|
||||
missing: ["libnss3.so", "libatk-1.0.so.0"],
|
||||
probeUnavailable: false,
|
||||
});
|
||||
vi.spyOn(linuxDeps, "detectLinuxDistro").mockReturnValue({
|
||||
family: "debian",
|
||||
id: "ubuntu",
|
||||
prettyName: "Ubuntu 22.04.3 LTS",
|
||||
isWsl: true,
|
||||
});
|
||||
|
||||
const result = await runEnvironmentChecks({ includeBrowser: true });
|
||||
const chrome = result.outcomes.find((o) => o.name === "Chrome");
|
||||
|
||||
expect(chrome).toMatchObject({
|
||||
ok: false,
|
||||
level: "error",
|
||||
title: "Chrome cannot launch (missing system libraries)",
|
||||
});
|
||||
expect(chrome?.detail).toContain("WSL");
|
||||
expect(chrome?.detail).toContain("libnss3.so");
|
||||
expect(chrome?.hint).toContain("apt-get install -y");
|
||||
expect(chrome?.hint).toContain("libnss3");
|
||||
// A lib-broken Chrome must NOT be handed to the render pipeline as usable.
|
||||
expect(result.browser).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps Chrome ok when the shared-lib probe passes", async () => {
|
||||
vi.spyOn(manager, "findBrowser").mockResolvedValue({
|
||||
executablePath: "/usr/bin/chromium",
|
||||
source: "system",
|
||||
});
|
||||
vi.spyOn(linuxDeps, "probeChromeSharedLibs").mockReturnValue({
|
||||
ok: true,
|
||||
missing: [],
|
||||
probeUnavailable: false,
|
||||
});
|
||||
|
||||
const result = await runEnvironmentChecks({ includeBrowser: true });
|
||||
expect(result.outcomes.find((o) => o.name === "Chrome")).toMatchObject({ ok: true });
|
||||
expect(result.browser?.executablePath).toBe("/usr/bin/chromium");
|
||||
});
|
||||
|
||||
it("keeps Chrome ok when the probe is inconclusive (no ldd)", async () => {
|
||||
vi.spyOn(manager, "findBrowser").mockResolvedValue({
|
||||
executablePath: "/usr/bin/chromium",
|
||||
source: "system",
|
||||
});
|
||||
vi.spyOn(linuxDeps, "probeChromeSharedLibs").mockReturnValue({
|
||||
ok: false,
|
||||
missing: [],
|
||||
probeUnavailable: true,
|
||||
});
|
||||
|
||||
const result = await runEnvironmentChecks({ includeBrowser: true });
|
||||
expect(result.outcomes.find((o) => o.name === "Chrome")).toMatchObject({ ok: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseToolVersion", () => {
|
||||
it("extracts ffprobe versions with Windows build suffixes", () => {
|
||||
expect(parseToolVersion("ffprobe version 7.1.1-essentials_build-www.gyan.dev Copyright")).toBe(
|
||||
|
||||
Reference in New Issue
Block a user