mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* ci(windows): probe that a render opens no visible window * ci(windows): the probe names what opened each window * ci(windows): the probe spawns each binary alone, with and without detached * ci(windows): the probe logs the processes started during the render * ci(windows): the probe also spawns Chrome one consoleless hop down * ci(windows): the probe logs each child started without windowsHide * ci(windows): the probe logs every child process with its windowsHide and detached * fix(engine): Chrome keeps the CLI's console on Windows, so a render opens no window * fix(cli): every child the CLI starts on Windows is hidden unless it opts out * ci(windows): the probe bisects Chrome's flags and keeps each command's output * ci(windows): the probe names the Chrome process behind each window * ci(windows): the probe loads a page in Chrome directly and one hidden hop down * ci(windows): the probe prints the Chrome main command line and renders with the reporter's flags * ci(windows): the probe narrows the CLI's Chrome arguments to the ones that open a window * ci(windows): the probe launches the CLI's Chrome arguments one hidden hop down * ci(windows): the probe launches Chrome through the engine's browser pool * ci(windows): the probe varies what the engine passes to Puppeteer * fix(engine): renders on Windows launch Chrome with a Puppeteer that keeps it attached * refactor(cli): hideChildConsoles copies its arguments and keeps one comment line
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import "./utils/hideChildConsoles.js";
|
|
import { writeFileSync } from "node:fs";
|
|
import { isAbsolute, join } from "node:path";
|
|
|
|
const QUIET_MS = 60_000;
|
|
|
|
interface Output {
|
|
write: (...args: never[]) => unknown;
|
|
}
|
|
|
|
/** Writes the report without environment values; before Node 22.13 that is impossible, so nothing is written. */
|
|
export function writeReportFile(
|
|
path: string,
|
|
report: Pick<typeof process.report, "getReport"> = process.report,
|
|
): boolean {
|
|
if (!("excludeEnv" in report)) return false;
|
|
report.excludeEnv = true;
|
|
// writeReport announces the file on stderr; getReport keeps the file the only trace.
|
|
writeFileSync(path, JSON.stringify(report.getReport()), { mode: 0o600 });
|
|
return true;
|
|
}
|
|
|
|
/** With HYPERFRAMES_HANG_REPORT=<absolute dir>, one diagnostic report after 60 s of silence; behaviour is unchanged. */
|
|
export function watchForHang(
|
|
outputs: readonly Output[] = [process.stdout, process.stderr],
|
|
env = process.env,
|
|
writeReport: (path: string) => unknown = writeReportFile,
|
|
): void {
|
|
const dir = env.HYPERFRAMES_HANG_REPORT;
|
|
if (!dir || !isAbsolute(dir)) return;
|
|
let timer: NodeJS.Timeout | undefined;
|
|
let written = false;
|
|
const arm = () => {
|
|
if (written) return;
|
|
clearTimeout(timer);
|
|
timer = setTimeout(() => {
|
|
written = true;
|
|
try {
|
|
writeReport(join(dir, `hang-${process.pid}.json`));
|
|
} catch {}
|
|
}, QUIET_MS).unref();
|
|
};
|
|
for (const output of outputs) {
|
|
const write = output.write.bind(output);
|
|
output.write = (...args: never[]) => {
|
|
arm();
|
|
return write(...args);
|
|
};
|
|
}
|
|
arm();
|
|
}
|