fix(hopper): report launcher failures before bridge timeout (#1105)

* fix(hopper): report launcher failures before bridge timeout

* fix(hopper): separate helper ownership from GUI lifetime
This commit is contained in:
Ysopwnable
2026-10-09 01:51:45 +08:00
committed by GitHub
parent 7914e36ab9
commit cd756b07d5
11 changed files with 270 additions and 28 deletions
@@ -27,6 +27,7 @@ class SilentLauncher implements BridgeLauncher {
},
),
ownsProcessLifetime: true as const,
providerLifetime: "launcher-process" as const,
shutdownMode: "bridge-request" as const,
}),
);
@@ -52,7 +53,10 @@ class CancelThenFixtureLauncher implements BridgeLauncher {
}
class ExitingLauncher implements BridgeLauncher {
constructor(readonly code: number) {}
constructor(
readonly code: number,
readonly ownsProcessLifetime = true,
) {}
launch() {
return Promise.resolve(
@@ -60,7 +64,10 @@ class ExitingLauncher implements BridgeLauncher {
process: spawn(process.execPath, ["-e", `process.exit(${this.code})`], {
stdio: ["ignore", "ignore", "pipe"],
}),
ownsProcessLifetime: true as const,
ownsProcessLifetime: this.ownsProcessLifetime,
providerLifetime: this.ownsProcessLifetime
? ("launcher-process" as const)
: ("external-application" as const),
shutdownMode: "bridge-request" as const,
}),
);
@@ -97,6 +104,7 @@ class DiagnosticExitingLauncher implements BridgeLauncher {
{ stdio: ["ignore", "ignore", "pipe"] },
),
ownsProcessLifetime: true as const,
providerLifetime: "launcher-process" as const,
shutdownMode: "bridge-request" as const,
}),
);
@@ -281,7 +289,7 @@ describe("HopperClient startup failures", () => {
it("allows a short-lived launcher to hand off bridge startup", async () => {
const client = new HopperClient({
launcher: new ExitingLauncher(0),
launcher: new ExitingLauncher(0, false),
startupTimeoutMs: 100,
});
clients.push(client);