mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-20 03:47:38 +00:00
* fix(cli): reap only orphaned browsers HyperFrames launched Orphan cleanup on preview and render killed every PPID-1 process of the current user whose args named chrome-headless-shell or a Puppeteer temp profile, which included detached browsers started by other tools. Every HyperFrames Chrome launch now passes an inert --hyperframes-owned-browser switch, and the reaper only kills PPID-1 processes that carry it as a whole argument. Fixes #6203 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(core): serve the browser marker from its own subpath The GCP image's BeginFrame contract step imports the engine's browserManager straight from source before core's generated runtime exists, so pulling the marker from the core root entry broke it. A dependency-free @hyperframes/core/browser-marker subpath keeps that import chain as light as it was. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(cli): expect the browser marker in the capture fallback launches Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(cli): say orphan cleanup runs before preview and render The cleanup only stops browsers HyperFrames launched, so the opt-out is no longer needed to protect other tools' browsers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
80 lines
2.9 KiB
TypeScript
80 lines
2.9 KiB
TypeScript
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { expect, it, vi } from "vitest";
|
|
import { HYPERFRAMES_BROWSER_MARKER_ARG } from "../../core/src/browserMarker";
|
|
import { Inspector } from "../src/service";
|
|
|
|
const launches = vi.hoisted(() => [] as { args?: string[] }[]);
|
|
|
|
vi.mock("puppeteer-core", () => ({
|
|
default: {
|
|
launch: async (options: { args?: string[] }) => {
|
|
launches.push(options);
|
|
return {
|
|
close: async () => {},
|
|
newPage: async () => {
|
|
let html = "";
|
|
return {
|
|
setViewport: async () => {},
|
|
goto: async (url: string) => {
|
|
html = await (await fetch(url)).text();
|
|
},
|
|
waitForFunction: async () => {},
|
|
evaluate: async () => {},
|
|
content: async () => html,
|
|
close: async () => {},
|
|
};
|
|
},
|
|
};
|
|
},
|
|
},
|
|
}));
|
|
|
|
it("reloads the standalone page when an HF ID is stamped onto disk", async () => {
|
|
const project = mkdtempSync(join(tmpdir(), "inspect-stamp-"));
|
|
const path = join(project, "index.html");
|
|
const source =
|
|
'<!doctype html><html><head></head><body><main data-composition-id="root" data-duration="10" data-width="1920" data-height="1080"><div id="target">Title</div></main></body></html>';
|
|
writeFileSync(path, source);
|
|
const inspector = new Inspector(project, {
|
|
executablePath: "browser-stand-in",
|
|
instrument: false,
|
|
});
|
|
try {
|
|
const first = await inspector.withPage((page) => page.content());
|
|
expect(first).toContain('id="target"');
|
|
expect(first).not.toContain('data-hf-id="hf-t1"');
|
|
expect(await inspector.withPage((page) => page.content())).toBe(first);
|
|
expect(inspector.stats.pageLoads).toBe(1);
|
|
writeFileSync(path, source.replace('id="target"', 'id="target" data-hf-id="hf-t1"'));
|
|
const stamped = await inspector.withPage((page) => page.content());
|
|
expect(stamped).toContain('data-hf-id="hf-t1"');
|
|
expect(inspector.stats.pageLoads).toBe(2);
|
|
} finally {
|
|
await inspector.dispose();
|
|
rmSync(project, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("launches its browser with the HyperFrames marker", async () => {
|
|
const project = mkdtempSync(join(tmpdir(), "inspect-marker-"));
|
|
writeFileSync(
|
|
join(project, "index.html"),
|
|
'<!doctype html><html><body><main data-composition-id="root" data-duration="1" data-width="64" data-height="64"></main></body></html>',
|
|
);
|
|
const inspector = new Inspector(project, {
|
|
executablePath: "browser-stand-in",
|
|
instrument: false,
|
|
});
|
|
try {
|
|
launches.length = 0;
|
|
await inspector.withPage((page) => page.content());
|
|
expect(launches).toHaveLength(1);
|
|
expect(launches[0]!.args).toContain(HYPERFRAMES_BROWSER_MARKER_ARG);
|
|
} finally {
|
|
await inspector.dispose();
|
|
rmSync(project, { recursive: true, force: true });
|
|
}
|
|
});
|