mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(cli): close every browser on SIGTERM and SIGINT through one launch owner * fix(cli): own SIGTERM before the GPU probe browser launches * fix(cli): keep tests on the managed GPU mode and drop the engine signal flag * test(cli): give the browser fallback fake a process handle * test(cli): signal the GPU probe case only once the signal owner is installed * test(cli): mark the launching case only after the signal owner is installed
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
// fallow-ignore-file unused-file
|
|
import { writeFileSync } from "node:fs";
|
|
import { registerRootExitRequester } from "../utils/commandResult.js";
|
|
import { ensureBrowser } from "./manager.js";
|
|
import { launchManagedBrowser, resolveManagedGpuMode } from "./launch.js";
|
|
|
|
const [profileDir, readyPath] = process.argv.slice(2);
|
|
if (!profileDir || !readyPath) throw new Error("Missing fixture arguments");
|
|
|
|
// Stand-in for cli.ts: records the requested exit code, then ends the process.
|
|
registerRootExitRequester((exitCode) => {
|
|
writeFileSync(`${readyPath}.exit`, String(exitCode));
|
|
process.kill(process.pid, "SIGKILL");
|
|
});
|
|
const { executablePath } = await ensureBrowser();
|
|
const puppeteer = await import("puppeteer-core");
|
|
if (process.argv[4] === "probe") {
|
|
// The signal owner is installed synchronously by the call, so "probing" is only written once a SIGTERM is handled.
|
|
const probe = resolveManagedGpuMode("auto", executablePath);
|
|
writeFileSync(readyPath, "probing");
|
|
await probe;
|
|
}
|
|
const launch = launchManagedBrowser(puppeteer.default, {
|
|
headless: true,
|
|
executablePath,
|
|
args: ["--no-sandbox", `--user-data-dir=${profileDir}`],
|
|
});
|
|
writeFileSync(readyPath, "launching");
|
|
const browser = await launch;
|
|
writeFileSync(readyPath, "ready");
|
|
await browser.pages();
|
|
setInterval(() => undefined, 1_000);
|