mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix(aws-lambda): match the shell to its own pin, ship only hashed files, refuse the shell ZIP in CDK and SAM (#8173)
* fix(aws-lambda): match the shell to its own pin, ship only hashed files, refuse the shell ZIP in CDK and SAM Review follow-ups to the pinned shell route: - build-zip --source=chrome-headless-shell accepts the folder only when its digest is pinned for this version, not for any pinned build. - It leaves out the files the digest skips (debug.log and chrome_debug.log, which Chrome writes as it runs), so nothing unhashed ships. - The CDK construct throws on chromeSource "chrome-headless-shell" and the SAM template allows only sparticuz, as lambda deploy already refused it: a shell ZIP cannot fit a function. The CHROME_PATH wiring for that ZIP is gone with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(aws-lambda): raise the packed size budget to 82,000 bytes The shipped build-zip script now checks the shell against its own version's pin and skips the files the digest leaves out. That takes the tarball to 81,378 bytes in CI, over the 80,500 budget's 1% tolerance; main was already within about 200 bytes of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9acf268680
commit
61d65e7177
@@ -1,8 +1,10 @@
|
||||
import { cpSync, existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { join, relative } from "node:path";
|
||||
import {
|
||||
isPinnedHeadlessShell,
|
||||
CHROME_WRITES_WHILE_RUNNING,
|
||||
headlessShellDigest,
|
||||
managedChromeVersion,
|
||||
PINNED_SHELL_DIGESTS,
|
||||
} from "@hyperframes/engine/chrome-host-ceiling";
|
||||
import { BUNDLED_SHELL_DIR } from "../src/chromium.js";
|
||||
|
||||
@@ -10,12 +12,13 @@ import { BUNDLED_SHELL_DIR } from "../src/chromium.js";
|
||||
* Stage the repo's pinned linux64 chrome-headless-shell from the Puppeteer cache under `home` into
|
||||
* `<stagingDir>/<BUNDLED_SHELL_DIR>/`. The whole folder: the executable alone exits at launch
|
||||
* ("Invalid file descriptor to ICU data received") without icudtl.dat and its .pak files.
|
||||
* Only the pinned build, and only when its folder matches the pinned digest. Returns the version.
|
||||
* Only the pinned build, and only when its folder matches that build's own pinned digest; the files the digest leaves
|
||||
* out are not copied. Returns the version.
|
||||
*/
|
||||
export function stageChromeHeadlessShell(
|
||||
stagingDir: string,
|
||||
home = process.env.HOME ?? "/root",
|
||||
isPinned: (executable: string) => boolean = isPinnedHeadlessShell,
|
||||
pinned: Readonly<Record<string, readonly string[]>> = PINNED_SHELL_DIGESTS,
|
||||
): string {
|
||||
const version = managedChromeVersion("linux");
|
||||
const cache = join(home, ".cache", "puppeteer");
|
||||
@@ -33,13 +36,17 @@ export function stageChromeHeadlessShell(
|
||||
`before --source=chrome-headless-shell.`,
|
||||
);
|
||||
}
|
||||
if (!isPinned(executable)) {
|
||||
const digest = headlessShellDigest(folder);
|
||||
if (digest === undefined || !(pinned[version] ?? []).includes(digest)) {
|
||||
throw new Error(
|
||||
`[build-zip] ${folder} does not match the pinned chrome-headless-shell ${version} digest. ` +
|
||||
`Delete it and install it again.`,
|
||||
);
|
||||
}
|
||||
// cpSync keeps each file's mode, so the executable stays executable.
|
||||
cpSync(folder, join(stagingDir, BUNDLED_SHELL_DIR), { recursive: true });
|
||||
cpSync(folder, join(stagingDir, BUNDLED_SHELL_DIR), {
|
||||
recursive: true,
|
||||
filter: (path) => !CHROME_WRITES_WHILE_RUNNING.includes(relative(folder, path)),
|
||||
});
|
||||
return version;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user