fix(cli): browser ensure fails when the unzip leaves no Chrome executable (#5329)

* fix(cli): browser ensure fails when the unzip leaves no Chrome executable

* refactor(cli): keep install debug output and report only the last unzip attempt

* fix(cli): browser ensure exits after a failure or a --force download

* fix(cli): browser checks name why Chrome could not be installed

* fix(cli): render shows why its setup step failed instead of a crash dump

* refactor(cli): build the browser download label and staged test path once

* refactor(cli): one owner for the render setup result line

* fix(cli): render setup failures report through one error line

* refactor(cli): one reader and writer for both render setup lines
This commit is contained in:
Miguel Ángel
2026-10-09 16:21:46 +00:00
committed by GitHub
parent 46f6cb3567
commit 577bdf6701
11 changed files with 363 additions and 109 deletions
+40 -1
View File
@@ -1,5 +1,11 @@
import { describe, expect, it, vi } from "vitest";
import { installRenderSetupSignalHandlers } from "./renderSetupWorkerLifecycle.js";
import {
installRenderSetupSignalHandlers,
renderSetupFailureFrom,
renderSetupErrorLine,
renderSetupResultFrom,
renderSetupResultLine,
} from "./renderSetupWorkerLifecycle.js";
describe("render setup worker signal lifecycle", () => {
function collectHandlers(handleHangup = true) {
@@ -53,3 +59,36 @@ describe("render setup worker signal lifecycle", () => {
},
);
});
describe("render setup worker failure line", () => {
it("carries the whole reason past the crash output around it", () => {
const reason =
"Failed to install chrome-headless-shell: missing.\n\n export HYPERFRAMES_BROWSER_PATH=x";
const failure = new Error(reason, { cause: new Error("tar.exe extraction failed") });
const stderr = [
"warning before",
renderSetupErrorLine(failure).trimEnd(),
"/worker.ts:20",
" throw error;",
"Error: Failed to install chrome-headless-shell: missing.",
" at downloadBrowser (manager.ts:845:11)",
].join("\n");
expect(renderSetupFailureFrom(stderr)).toEqual({ reason, earlierOutput: "warning before" });
});
it.each([
["a worker that crashed without one", "Error: boom\n at x (y.ts:1:1)"],
["a cut-off line", 'HYPERFRAMES_RENDER_SETUP_ERROR:"Failed to ins'],
["an empty message", renderSetupErrorLine(new Error(""))],
])("finds no reason in %s, so the parent shows the raw output", (_label, stderr) => {
expect(renderSetupFailureFrom(stderr)).toBeUndefined();
});
it("reads back the result line the worker writes", () => {
const result = { executablePath: "/chrome", source: "cache" };
expect(renderSetupResultFrom(`noise\n${renderSetupResultLine(result)}`)).toEqual(result);
expect(renderSetupResultFrom("noise only")).toBeUndefined();
});
});