Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): desktop backend now exits when its launcher dies #20277

Mergedbompus(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/20277/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 120 additions and 1 deletion.

x
0 of 3 viewed, 3 left
10 additions and 1 deletionapps/server/src/cli/server.tsModified
View file
@@ -7,6 +7,7 @@
import * as CliError from "effect/cli/CliError";
​
import * as ServerConfig from "../config.ts";
+import { awaitLauncherLoss } from "../launcherWatch.ts";
import { runServer } from "../server.ts";
import { type CliServerFlags, resolveServerConfig, sharedServerCommandFlags } from "./config.ts";
​
@@ -23,7 +24,15 @@
Effect.gen(function* () {
const logLevel = yield* GlobalFlag.LogLevel;
const config = yield* resolveServerConfig(flags, logLevel, options);
- return yield* runServer.pipe(Effect.provideService(ServerConfig.ServerConfig, config));
+ const run = runServer.pipe(Effect.provideService(ServerConfig.ServerConfig, config));
+ if (config.mode !== "desktop" || config.desktopBootstrapToken === undefined) return yield* run;
+ return yield* Effect.raceFirst(
+ run,
+ awaitLauncherLoss().pipe(
+ // End like SIGTERM does (interrupt-only exit, so the runtime forces process exit).
+ Effect.andThen(Effect.interrupt),
+ ),
+ );
});
​
export const runDefaultServerCommand = (flags: CliServerFlags) =>
65 additions and 0 deletionsapps/server/src/launcherWatch.test.tsAdded
View file
@@ -0,0 +1,65 @@