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.

fix(gateway): wait for launcher handoff before tracking tunnel identity

Rahmanb8b2241c7454
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 802f1086..27458d29 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `gateway` wait for launcher handoff before tracking tunnel identity
- `build` separate runtime inputs and clarify mobile MCP guides
- `a11y` label settings controls and expose selected options
- `settings` clarify MCP navigation and enforce zero-warning tests
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 50efcdf8..eb6a484c 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,7 @@
+## 2026-09-09 — Gateway release handshake under CI scheduling
+
+The final GitHub run exposed a remaining startup race: the held child already carries target argv, so command matching could acknowledge it before it consumed its release gate. Matching now refuses that exact launcher. Quick URL discovery pins the spawned PID/start ticks while wrappers exec; final readiness still requires exact executable/argv before state commits. The concurrent-start regression delays URL publication after interpreter exec, while checking one tracked live tunnel and successful cleanup. No timeouts, skips or identity checks were weakened to obtain a pass.
+
## 2026-09-09 — Runtime build boundaries and mobile setup follow-up
Deployment log inspection caught sixteen additional Turbopack warnings. Instrumentation now places Node-only imports inside explicit positive runtime branches, following the Next instrumentation contract (https://nextjs.org/docs/app/guides/instrumentation). Host state, credentials, external Git metadata and installed executables are explicitly runtime-only filesystem inputs rather than traced application assets; existing authorization, containment, size and symlink checks remain intact. The release build now rejects warning output instead of discarding it on successful compilation. MCP setup leads with numbered actions and puts optional display metadata below them; copy text wraps at word boundaries on narrow screens.
diff --git a/scripts/lib/gateway-common.sh b/scripts/lib/gateway-common.sh
index b090d67f..2af3ddf9 100644
--- a/scripts/lib/gateway-common.sh
+++ b/scripts/lib/gateway-common.sh
@@ -128,6 +128,11 @@ gateway_command_matches() {
local -a argv expected=("$@")
gateway_pid_alive "$pid" || return 1
mapfile -d '' -t argv <"/proc/$pid/cmdline" 2>/dev/null || return 1
+ # The held launcher carries the target argv before it consumes the release gate.
+ # Never acknowledge that wrapper or remove its gate before the actual exec.
+ for i in "${argv[@]}"; do
+ [ "$i" != "$ROOT/scripts/lib/gateway-held-child.sh" ] || return 1
+ done
for ((i=0; i<${#argv[@]}; i++)); do
[ "${argv[$i]}" = "$marker" ] || continue
[ "$(( ${#argv[@]} - i - 1 ))" -eq "${#expected[@]}" ] || return 1
diff --git a/scripts/lib/gateway-tunnel.sh b/scripts/lib/gateway-tunnel.sh
index 5dac8161..f5aa9272 100644
--- a/scripts/lib/gateway-tunnel.sh
+++ b/scripts/lib/gateway-tunnel.sh
@@ -102,7 +102,9 @@ gateway_discover_quick_url() {
for i in $(seq 1 80); do
GATEWAY_PUBLIC_URL="$(grep -Eo 'https://[A-Za-z0-9-]+\.trycloudflare\.(com|app)' "$CF_LOG" | tail -1 || true)"
[ -n "$GATEWAY_PUBLIC_URL" ] && return 0
- gateway_identity_matches_retry "$TUNNEL_IDENTITY" || return 1
+ # Startup may legitimately exec an interpreter before publishing the URL.
+ # Pin the spawned lifetime here; require exact executable/argv after readiness.
+ [ "$(gateway_proc_start_ticks "$pid" 2>/dev/null || true)" = "$TUNNEL_PENDING_TICKS" ] || return 1
sleep 0.25
done
return 1
diff --git a/scripts/mso-gateway-recovery.test.ts b/scripts/mso-gateway-recovery.test.ts
index 60282fdd..ed28ecea 100644
--- a/scripts/mso-gateway-recovery.test.ts
+++ b/scripts/mso-gateway-recovery.test.ts
@@ -46,6 +46,10 @@ exec /bin/mv "$@"
it.each(["direct", "interpreter exec"])("serializes concurrent starts so only one tunnel remains live and tracked (%s)", async mode => {
const f = fixture(), startFile = f.startFile, env = f.env;
if (mode === "interpreter exec") {
+ // Emit readiness after exec so discovery must tolerate the identity transition.
+ fs.writeFileSync(f.cloudflared, fs.readFileSync(f.cloudflared, "utf8").replace(
+ "console.error('INF https://life-fixture.trycloudflare.com')",
+ "setTimeout(() => console.error('INF https://life-fixture.trycloudflare.com'), 700)"));
fs.renameSync(f.cloudflared, f.cloudflared + ".cjs");
// Preserve PID/start ticks while startup changes executable and argv.
fs.writeFileSync(f.cloudflared, `#!/bin/bash
@@ -54,7 +58,7 @@ exec node -e 'require(process.argv[1] + ".cjs")' "$0" "$@"
`, { mode: 0o700 });
}
const [a, b] = await Promise.all([asyncStart(env), asyncStart(env)]);
- expect(a.code).toBe(0); expect(b.code).toBe(0);
+ expect(a.code, a.stderr).toBe(0); expect(b.code, b.stderr).toBe(0);
const spawned = fs.readFileSync(startFile, "utf8").trim().split(/\n+/).filter(Boolean).map(Number);
for (const pid of spawned) pids.add(pid);
expect(spawned).toHaveLength(1);