diff --git a/packages/daemon/src/worker-runtime.ts b/packages/daemon/src/worker-runtime.ts index e490a19..2be1068 100644 --- a/packages/daemon/src/worker-runtime.ts +++ b/packages/daemon/src/worker-runtime.ts @@ -187,7 +187,6 @@ export function createWorkerRuntime( if (isReadyIpcMessage(msg)) { if (slot.state === "starting") { slot.state = "ready"; - slot.crashTimestamps = []; config.onReady(slot.key, msg); resolveReadyWaiters(slot); } @@ -272,7 +271,11 @@ export function createWorkerRuntime( slot.expectExit = true; slot.state = "draining"; const child = slot.child; - child.send({ type: "shutdown" }); + try { + child.send({ type: "shutdown" }); + } catch { + // IPC channel may have closed between null-check and send + } await waitForChildExit(child, config.shutdownTimeoutMs); } @@ -330,8 +333,12 @@ export function createWorkerRuntime( if (child === null || !child.connected) { return false; } - child.send(msg as Serializable); - return true; + try { + child.send(msg as Serializable); + return true; + } catch { + return false; + } }, start: async (key: K) => {