Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(vps): report the SSH error or a timeout, not the raw command line, when initialization fails

Sebastian B7d0c840c1ac7
diff --git a/server/vps-ssh-init.test.ts b/server/vps-ssh-init.test.ts
index 29b4546c9b..b9ff0a5adf 100644
--- a/server/vps-ssh-init.test.ts
+++ b/server/vps-ssh-init.test.ts
@@ -101,6 +101,11 @@ describe.skipIf(process.platform === "win32")("cold VPS SSH startup", () => {
fixture.failInitialization();
const results = await Promise.allSettled(Array.from({ length: 4 }, () => defaultRunner(target("failed-vps", "run"))));
expect(results.every(result => result.status === "rejected")).toBe(true);
+ for (const result of results) {
+ const message = String((result as PromiseRejectedResult).reason?.message);
+ expect(message).toContain("synthetic SSH failure");
+ expect(message).not.toContain("Command failed");
+ }
expect(commands(fixture.calls)).toHaveLength(0);
expect(fixture.calls.filter(args => args.at(-1) === "true")).toHaveLength(1);
fixture.release();
diff --git a/server/vps-ssh.ts b/server/vps-ssh.ts
index e9ae7c02ce..e152e1825d 100644
--- a/server/vps-ssh.ts
+++ b/server/vps-ssh.ts
@@ -107,7 +107,12 @@ export async function ensureVpsSshMaster(ssh: VpsSshSetup, alias: string, timeou
timeout: remaining,
killSignal: "SIGKILL",
maxBuffer: 64 * 1024,
- }, error => error ? reject(error) : resolve());
+ }, (error, _stdout, stderr) => {
+ if (!error) { resolve(); return; }
+ const killed = (error as { killed?: boolean }).killed === true;
+ const detail = killed ? "VPS SSH initialization timed out" : String(stderr).trim().slice(-1000) || error.message;
+ reject(Object.assign(new Error(detail), { killed }));
+ });
child.stdin?.end();
});
pending = (async () => {