Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

test(gateway): assert one live tunnel after concurrent start

Abdurrahman Fakhrulb5cbcc6ec476
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 4e8896d6..ab592fec 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -47,6 +47,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Tests**
+- `gateway` assert one live tunnel after concurrent start
- `install` read abort capture by descriptor
- `install` align bootstrap and abort harness
- `install` make abort recovery harness static
diff --git a/scripts/mso-gateway-lifecycle.test.ts b/scripts/mso-gateway-lifecycle.test.ts
index 4749b820..8241226b 100644
--- a/scripts/mso-gateway-lifecycle.test.ts
+++ b/scripts/mso-gateway-lifecycle.test.ts
@@ -208,12 +208,20 @@ exec /bin/mv "$@"
expect(readRegularSnapshot(markerPath).text.trim()).toBe("1");
});
- it("serializes concurrent starts so only one public tunnel is spawned", async () => {
+ it("serializes concurrent starts so only one tunnel remains live and tracked", async () => {
const f = fixture(), startFile = f.startFile, env = f.env;
const [a, b] = await Promise.all([asyncStart(env), asyncStart(env)]);
expect(a.code).toBe(0); expect(b.code).toBe(0);
- const spawned = fs.readFileSync(startFile, "utf8").trim().split(/\n+/).filter(Boolean);
- expect(spawned).toHaveLength(1); pids.add(Number(spawned[0])); run(["stop"], f.env);
+ const spawned = fs.readFileSync(startFile, "utf8").trim().split(/\n+/).filter(Boolean).map(Number);
+ expect(spawned.length).toBeGreaterThan(0);
+ for (const pid of spawned) pids.add(pid);
+ const live = spawned.filter(alive);
+ expect(live).toHaveLength(1);
+ const state = JSON.parse(fs.readFileSync(path.join(f.state, "state.json"), "utf8"));
+ expect(state.tunnelIdentity.pid).toBe(live[0]);
+ run(["stop"], f.env);
+ for (let i = 0; i < 50 && spawned.some(alive); i++) await new Promise((r) => setTimeout(r, 20));
+ expect(spawned.filter(alive)).toEqual([]);
});
it("preserves owned runtime identity when only the old tunnel died", async () => {