From 7e7f6aa6d631dd6df39deb5598abb79e90a2230b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Sat, 9 May 2026 12:38:18 +0000 Subject: [PATCH] fix: detect crashed threads by checking worker PID liveness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When .running marker exists but no __end__ in CAS chain, check if the worker process is actually alive. Dead PID means the worker crashed without cleanup → status 'failed'. Fixes #170 小橘 --- packages/cli-workflow/src/thread-scan.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/cli-workflow/src/thread-scan.ts b/packages/cli-workflow/src/thread-scan.ts index 6e161de..fbcc381 100644 --- a/packages/cli-workflow/src/thread-scan.ts +++ b/packages/cli-workflow/src/thread-scan.ts @@ -11,6 +11,7 @@ import { END } from "@uncaged/workflow-runtime"; import { getGlobalCasDir } from "@uncaged/workflow-util"; import { pathExists, readTextFileIfExists } from "./fs-utils.js"; +import { readWorkerCtl } from "./worker-spawn.js"; async function readWorkflowNameFromStartHash( storageRoot: string, @@ -217,6 +218,16 @@ export async function resolveThreadListStatus( return "completed"; } if (runningMarkerPresent) { + const ctlResult = await readWorkerCtl(storageRoot, row.hash); + if (ctlResult.ok) { + try { + process.kill(ctlResult.value.pid, 0); + return "running"; + } catch { + // Worker PID is dead but .running marker remains — crashed thread + return "failed"; + } + } return "running"; } return "active";