The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 19:30 UTC
fix(server): a desktop backend whose launcher died shuts down cleanly instead of crashing (#22471)
Dara Adedeji committed
Oct 21, 2026 at 17:08 UTC
2936b90883b2e23b00e1c2a5361ea545c3ac8dff
1 file changed
+11
apps/server/src/cli/server.ts
+11
@@ -13,6 +13,13 @@ import { type CliServerFlags, resolveServerConfig, sharedServerCommandFlags } fr
13
14
const encodeCommand = Schema.encodeEffect(Schema.fromJsonString(Schema.String));
15
16
+// The desktop launcher reads this process's stdout and stderr. Once it is gone,
17
+// every log write fails, and Node turns an unhandled stream error into a crash
18
+// that skips shutdown and leaves the ownership lock and runtime record behind.
19
+function ignoreClosedLauncherPipe(error: NodeJS.ErrnoException): void {
20
+ if (error.code !== "EPIPE" && error.code !== "ERR_STREAM_DESTROYED") throw error;
21
+}
22
+
23
const runServerCommand = Effect.fn("server.runServerCommand")(function* (
24
flags: CliServerFlags,
25
options?: {
@@ -25,6 +32,10 @@ const runServerCommand = Effect.fn("server.runServerCommand")(function* (
32
const config = yield* resolveServerConfig(flags, logLevel, options);
33
const run = runServer.pipe(Effect.provideService(ServerConfig.ServerConfig, config));
34
if (config.mode !== "desktop" || config.desktopBootstrapToken === undefined) return yield* run;
35
+ yield* Effect.sync(() => {
36
+ process.stdout.on("error", ignoreClosedLauncherPipe);
37
+ process.stderr.on("error", ignoreClosedLauncherPipe);
38
+ });
39
return yield* Effect.raceFirst(
40
run,
41
awaitLauncherLoss().pipe(