fix(linux): start Hopper demo sessions headlessly

This commit is contained in:
morluto
2026-07-14 04:58:45 +08:00
parent 08d5b913b0
commit 75818d119e
18 changed files with 816 additions and 169 deletions
+5
View File
@@ -70,6 +70,7 @@ export class HopperClient {
#nextId = 1;
#buffer = "";
#closing = false;
#launcherExitCode: number | null | undefined;
#startPromise: Promise<Result<HopperServerInfo, HopperError>> | undefined;
#closePromise: Promise<void> | undefined;
@@ -102,6 +103,7 @@ export class HopperClient {
}
const socketPath = join(this.#directory, "bridge.sock");
this.#token = randomBytes(32).toString("hex");
this.#launcherExitCode = undefined;
const runId = randomUUID();
const launched = await this.#options.launcher.launch(
{
@@ -210,6 +212,8 @@ export class HopperClient {
while (Date.now() < deadline) {
if (signal?.aborted === true) return err(new HopperCancelledError());
if (this.#closing) return err(new HopperProcessError(null));
if (this.#launcherExitCode === 78)
return err(new HopperProcessError(this.#launcherExitCode));
try {
await access(socketPath);
} catch {
@@ -305,6 +309,7 @@ export class HopperClient {
});
});
launch.process.on("exit", (code) => {
this.#launcherExitCode = code;
this.#options.onDiagnostic?.({ type: "launcher-exit", code });
if (launch.ownsProcessLifetime && !this.#closing) {
this.#failAll(new HopperProcessError(code));