{"record":{"id":"08088a7293c48048","repo":"thedotmack/claude-mem","slug":"live-pid-detected-but-worker-did-not-become-ready","errorCode":null,"errorMessage":"Live PID detected but worker did not become ready before timeout","messagePattern":"Live PID detected but worker did not become ready before timeout","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/worker-spawner.ts","lineNumber":104,"sourceCode":"    return 'dead';\n  }\n\n  const pidFileStatus = cleanStalePidFile();\n  if (pidFileStatus === 'alive') {\n    logger.info('SYSTEM', 'Worker PID file points to a live process, skipping duplicate spawn');\n    const ready = await waitForReadiness(port, getPlatformTimeout(HOOK_TIMEOUTS.READINESS_WAIT));\n    if (ready) {\n      clearWorkerSpawnAttempted();\n      logger.info('SYSTEM', 'Worker became ready while waiting on live PID');\n      return 'ready';\n    }\n    const workerStillHealthy = await waitForHealth(port, 1000);\n    const workerPidStillAlive = cleanStalePidFile() === 'alive';\n    if (!workerStillHealthy && !workerPidStillAlive) {\n      logger.error('SYSTEM', 'Live PID disappeared before readiness endpoint became available');\n      return 'dead';\n    }\n    logger.warn('SYSTEM', 'Live PID detected but worker did not become ready before timeout');\n    return 'warming';\n  }\n\n  if (await waitForHealth(port, 1000)) {\n    clearWorkerSpawnAttempted();\n    const ready = await waitForReadiness(port, getPlatformTimeout(HOOK_TIMEOUTS.READINESS_WAIT));\n    if (!ready) {\n      logger.warn('SYSTEM', 'Worker is alive but readiness timed out — proceeding anyway');\n    }\n    logger.info('SYSTEM', 'Worker already running and healthy');\n    return ready ? 'ready' : 'warming';\n  }\n\n  const portInUse = await isPortInUse(port);\n  if (portInUse) {\n    logger.info('SYSTEM', 'Port in use, waiting for worker to become healthy');\n    const healthy = await waitForHealth(port, getPlatformTimeout(HOOK_TIMEOUTS.PORT_IN_USE_WAIT));\n    if (healthy) {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/services/worker-spawner.ts#L86-L122","documentation":"ensureWorkerStarted() found a live pid in the PID file and waited the readiness window (~30s, platform-adjusted) for /readiness, which reports DB plus search initialization. Readiness never came, but the process is still alive and at least somewhat healthy, so the spawner returns 'warming' — the worker exists, memory is not fully initialized yet.","triggerScenarios":"Large Chroma collection or transcript backlog making DB/search init exceed READINESS_WAIT; cold caches after reboot; first-run dependency setup (uv installing Python deps) stretching startup.","commonSituations":"Big existing memory databases after an upgrade that runs a migration; under-provisioned machines; concurrent disk-heavy work starving the worker's init.","solutions":["Wait and re-check — `claude-mem status` or GET /readiness usually turns ready within another minute","If it never becomes ready, read worker logs for the init step that stalls (search index build, DB migration)","For persistent slowness, reduce the transcript backlog or increase READINESS_WAIT via the platform timeout mechanism"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function waitForWorkerReady(port: number, timeoutMs = 60000): Promise<boolean> {\n  const deadline = Date.now() + timeoutMs;\n  while (Date.now() < deadline) {\n    try { if (await fetch(`http://127.0.0.1:${port}/readiness`).then(r => r.ok)) return true; } catch {}\n    await new Promise(r => setTimeout(r, 1000));\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 'warming' as pending, not failure — retry after a wait instead of force-spawning another worker","Poll /readiness rather than the PID file or /health to judge usability","Keep transcript/search backlogs small so init stays inside the readiness window"],"tags":["worker","readiness","startup","timeout"],"backgroundTag":"service-not-ready","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}