{"record":{"id":"dce40710ae11e267","repo":"thedotmack/claude-mem","slug":"worker-unavailable-on-windows-skipping-spawn-re","errorCode":null,"errorMessage":"Worker unavailable on Windows — skipping spawn (recent attempt failed within cooldown)","messagePattern":"Worker unavailable on Windows — skipping spawn \\(recent attempt failed within cooldown\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/worker-spawner.ts","lineNumber":171,"sourceCode":"        port,\n        killedPids: reclaim.killedPids,\n      });\n      // The cooldown marker may have been written by the very spawn attempts\n      // this ghost blocked; the reason for those failures is now gone, so a\n      // time-based cooldown would only delay the recovery that just became\n      // possible (the plan-15 \"cooldowns keyed to evidence, not time\" rule).\n      clearWorkerSpawnAttempted();\n    } else {\n      logger.error('SYSTEM', 'Port in use but worker not responding to health checks', {\n        port,\n        reclaimReason: reclaim.reason,\n      });\n      return 'dead';\n    }\n  }\n\n  if (shouldSkipSpawnOnWindows()) {\n    logger.warn('SYSTEM', 'Worker unavailable on Windows — skipping spawn (recent attempt failed within cooldown)');\n    return 'dead';\n  }\n\n  // Spawn gate (src/shared/worker-spawn-gate.ts): only ONE gated launcher —\n  // hook, MCP server, or the CLI restart fallback — may spawn at a time. (The\n  // dying worker's restart handoff in worker-shutdown.ts is deliberately NOT\n  // gated: it is the primary spawner on restart, and hooks wait for its\n  // successor.) Losing the lock never fails this path; the loser skips its\n  // spawn and waits for the holder's worker. The winner holds the lock through\n  // the readiness wait and releases it in finally on every exit path.\n  const spawnLockHeld = acquireSpawnLock();\n  let spawnedPid: number | undefined;\n  try {\n    if (spawnLockHeld) {\n      logger.info('SYSTEM', 'Starting worker daemon', { workerScriptPath });\n      markWorkerSpawnAttempted();\n      spawnedPid = spawnDaemon(workerScriptPath, port);\n      if (spawnedPid === undefined) {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/worker-spawner.ts#L153-L189","documentation":"On Windows, the spawner consults shouldSkipSpawnOnWindows(), which returns true if a recent spawn attempt failed within the cooldown window. Rather than retry-spawning a worker known to have just failed, ensureWorkerStarted logs this warning and returns 'dead' immediately.","triggerScenarios":"Worker is not running, a previous spawn attempt on Windows failed recently (recorded attempt flag within cooldown), and shouldSkipSpawnOnWindows() gates the spawn — common because Windows spawn/kill cycles are slower and flakier.","commonSituations":"Repeated hook invocations right after a worker crash on Windows; uv/Bun missing or slow on first run; antivirus locking the spawned binary; cooldown not yet expired after a failed boot.","solutions":["Wait for the cooldown to expire and retry the operation","Fix the underlying spawn failure (check that Bun and uv are installed and on PATH)","Clear the spawn-attempted state / restart the machine if the flag is stale","Run the worker manually once to surface the real boot error"],"exampleFix":"// before\nif (shouldSkipSpawnOnWindows()) return 'dead';\n// after\nif (shouldSkipSpawnOnWindows()) {\n  logger.warn('spawn skipped: cooldown active; clearing after manual fix');\n  clearWorkerSpawnAttempted(); // once the root cause is fixed\n}","handlingStrategy":"fallback","validationCode":"if (process.platform === 'win32' && recentSpawnFailedWithinCooldown()) {\n  console.warn('spawn gated by cooldown; run worker manually to see the real error');\n}","typeGuard":null,"tryCatchPattern":"const status = await ensureWorkerStarted(port);\nif (status === 'dead' && process.platform === 'win32') {\n  // fall back to non-worker path or surface setup instructions\n}","preventionTips":["Install Bun and uv before first run on Windows","Clear the spawn-attempted flag after fixing a spawn failure","Test worker boot manually to surface errors the cooldown hides"],"tags":["windows","worker","spawn","cooldown"],"backgroundTag":"unsupported-platform","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}