Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): service launcher starts its server again once another server lets go of the T3 home #24230

Closedshivamhwp(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/24230/headopened View on GitHub

Showing 2 changed files with 138 additions and 9 deletions.

x
0 of 2 viewed, 2 left
80 additions and 5 deletionsapps/server/src/serviceLauncher.test.tsModified
View file
@@ -1,5 +1,6 @@
// @effect-diagnostics-next-line nodeBuiltinImport:off - observes the children the launcher spawns with Node built-ins.
import type * as NodeChildProcess from "node:child_process";
+import * as NodeSqlite from "node:sqlite";
​
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
@@ -16,6 +17,7 @@
readServiceEnvironment,
type BackupSpaceProbe,
readServiceState,
+ stateDirOwned,
writeServiceState,
} from "./serviceLauncher.ts";
import {
@@ -28,12 +30,16 @@
} from "./cloud/serviceProtocol.ts";
​
const spawnedChildren = vi.hoisted((): Array<NodeChildProcess.ChildProcess> => []);
+const spawnHook = vi.hoisted(() => ({
+ current: undefined as ((child: NodeChildProcess.ChildProcess) => void) | undefined,
+}));
​
vi.mock("node:child_process", async (importOriginal) => {
const actual = await importOriginal<typeof NodeChildProcess>();
const spawn = (...args: Parameters<typeof actual.spawn>) => {
const child = actual.spawn(...args);
spawnedChildren.push(child);
+ spawnHook.current?.(child);