Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: treat zombie owner as dead in vitestStaleRunRoots and await killed launcher (#12110)
Adam Eivya53c3fc68d01
diff --git a/scripts/lib/vitestStaleRunRoots.js b/scripts/lib/vitestStaleRunRoots.jsindex c85d39582f..f778269a30 100644--- a/scripts/lib/vitestStaleRunRoots.js+++ b/scripts/lib/vitestStaleRunRoots.js@@ -27,36 +27,58 @@ export function writeOwnerFile(root) {writeFileSync(join(root, OWNER_FILE), `${process.pid} ${startMs}\n`);}-/** Start time of a live pid in ms, or null when it cannot be read (always null on win32). */-function readProcessStartMs(pid) {+/** Process state and start time of a live pid, or null when it cannot be read (always null on win32). */+function readProcessInfo(pid, { exec = execFileSync } = {}) {if (process.platform === 'win32') return null;try {- const out = execFileSync('ps', ['-o', 'lstart=', '-p', String(pid)], {+ const out = exec('ps', ['-o', 'stat=,lstart=', '-p', String(pid)], {encoding: 'utf8',windowsHide: true,stdio: ['ignore', 'pipe', 'ignore'],env: { ...process.env, LC_ALL: 'C' },}).trim();- const ms = Date.parse(out);- return Number.isNaN(ms) ? null : ms;+ if (!out) return null;+ const match = /^(\S+)\s+(.+)$/.exec(out);+ if (!match) return null;+ const stat = match[1];+ const ms = Date.parse(match[2].trim());+ return {+ zombie: stat.startsWith('Z'),+ startMs: Number.isNaN(ms) ? null : ms,+ };} catch {return null;}}+/** Start time of a live pid in ms, or null when it cannot be read or is a zombie. */+function readProcessStartMs(pid, options) {+ const info = readProcessInfo(pid, options);+ return info?.zombie ? null : (info?.startMs ?? null);+}+/*** true = owner alive, false = owner gone (or pid reused), null = unknown.* `process.kill(pid, 0)` throws ESRCH for a missing pid and EPERM for a live* pid owned by someone else (alive).*/-export function isOwnerAlive({ pid, startMs }) {+export function isOwnerAlive({ pid, startMs }, { exec = execFileSync } = {}) {try {process.kill(pid, 0);} catch (err) {if (err.code === 'ESRCH') return false;if (err.code !== 'EPERM') return null;}- const liveStart = readProcessStartMs(pid);+ const info = readProcessInfo(pid, { exec });+ if (info?.zombie) return false;+ if (!info && process.platform !== 'win32') {+ try {+ process.kill(pid, 0);+ } catch (err) {+ if (err.code === 'ESRCH') return false;+ }+ }+ const liveStart = info?.startMs ?? null;if (liveStart === null || !Number.isFinite(startMs)) return true;return Math.abs(liveStart - startMs) <= START_TOLERANCE_MS;}diff --git a/scripts/run-ci-tests.test.js b/scripts/run-ci-tests.test.jsindex 643742854d..3b073d3d65 100644--- a/scripts/run-ci-tests.test.js+++ b/scripts/run-ci-tests.test.js@@ -695,6 +695,7 @@ describe('report launcher subprocess lifecycle (#9804)', () => {killProcessTree({ pid: doomedPids.group }, 'SIGKILL', { processGroup: true });}await doomed.closed;+ await waitFor(() => !alive(doomed.child.pid), 'doomed launcher survived SIGKILL');expect(existsSync(deadRoot)).toBe(true);const next = launch(host, 'success');runs.push(next);diff --git a/server/test/staleRunRoots.test.js b/server/test/staleRunRoots.test.jsindex 8949f61e26..619c766114 100644--- a/server/test/staleRunRoots.test.js+++ b/server/test/staleRunRoots.test.js@@ -76,4 +76,10 @@ describe('isOwnerAlive', () => {vi.spyOn(process, 'platform', 'get').mockReturnValue('win32');expect(isOwnerAlive({ pid: process.pid, startMs: 1 })).toBe(true);});++ it('treats a zombie process as dead', () => {+ if (process.platform === 'win32') return;+ const exec = () => 'Z+ Sun Oct 18 02:55:38 2026\n';+ expect(isOwnerAlive({ pid: process.pid, startMs: Date.now() }, { exec })).toBe(false);+ });});