{"record":{"id":"e16670daaf0995c1","repo":"thedotmack/claude-mem","slug":"uninstall-worker-shutdown-attempt-failed","errorCode":null,"errorMessage":"[uninstall] Worker shutdown attempt failed:","messagePattern":"\\[uninstall\\] Worker shutdown attempt failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/uninstall.ts","lineNumber":278,"sourceCode":"    const shouldContinue = await p.confirm({\n      message: 'Are you sure you want to uninstall claude-mem?',\n      initialValue: false,\n    });\n\n    if (p.isCancel(shouldContinue) || !shouldContinue) {\n      p.cancel('Uninstall cancelled.');\n      return;\n    }\n  }\n\n  const workerPort = SettingsDefaultsManager.get('CLAUDE_MEM_WORKER_PORT');\n  try {\n    const result = await shutdownWorkerAndWait(workerPort, 10000);\n    if (result.workerWasRunning) {\n      p.log.info('Worker service stopped.');\n    }\n  } catch (error: unknown) {\n    console.warn('[uninstall] Worker shutdown attempt failed:', error instanceof Error ? error.message : String(error));\n  }\n\n  // #2568 — server-runtime teardown. Gated on the installed/selected runtime so\n  // the worker uninstall path is completely unchanged. The bundled Docker\n  // compose stack lives under the marketplace dir; if it's present we treat the\n  // stack as locally managed and instruct teardown (the actual `docker compose\n  // down -v` is an operator/CI side effect, not run from this Node process).\n  const selectedRuntime = readSelectedRuntime();\n  if (selectedRuntime === 'server') {\n    if (existsSync(join(marketplaceDirectory(), 'docker-compose.yml'))) {\n      p.log.info(\n        'Server runtime detected. Tear down the bundled stack with '\n          + '`docker compose down -v --remove-orphans` (stops + removes pg + redis/valkey).',\n      );\n    } else {\n      p.log.info('Server runtime detected (externally managed stack — leaving Docker/pg/redis untouched).');\n    }\n    clearServerRuntimeSettings(SERVER_RUNTIME_SETTINGS_KEYS);","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/uninstall.ts#L260-L296","documentation":"Before removing files, runUninstallCommand() calls shutdownWorkerAndWait(CLAUDE_MEM_WORKER_PORT, 10000) to stop the background worker service. Any throw, such as the worker HTTP endpoint failing, a shutdown request error, or the worker not stopping within the 10-second budget, is caught and warned; uninstall continues, so the worker can still be alive after uninstall completes.","triggerScenarios":"`npx claude-mem uninstall` when the worker is wedged by a stuck job, CLAUDE_MEM_WORKER_PORT in settings no longer matches the running worker, the worker needs more than 10 seconds to drain and exit, or it already died in a way that raises instead of reporting workerWasRunning=false.","commonSituations":"Worker stuck mid-compression or embedding job; the port changed manually after install; machine resumed from sleep with a half-dead worker process.","solutions":["Check for a survivor after uninstall: lsof -i :<port> or ps aux | grep claude-mem, and kill it","Verify CLAUDE_MEM_WORKER_PORT in ~/.claude/settings.json matches the port the worker actually uses","Re-run `npx claude-mem uninstall` once the worker is stopped or healthy","A reboot also clears a wedged worker if the files are already removed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isErrnoException(error: unknown): error is NodeJS.ErrnoException {\n  return error instanceof Error && typeof (error as NodeJS.ErrnoException).code === 'string';\n}","tryCatchPattern":"try {\n  const result = await shutdownWorkerAndWait(workerPort, 10_000);\n  if (result.workerWasRunning) p.log.info('Worker service stopped.');\n} catch (error) {\n  if (isErrnoException(error) && ['ECONNREFUSED', 'ETIMEDOUT', 'ECONNRESET'].includes(error.code)) {\n    // worker gone or wedged: find and kill the process by port instead of retrying HTTP\n  } else {\n    console.warn('[uninstall] Worker shutdown attempt failed:', error instanceof Error ? error.message : String(error));\n  }\n}","preventionTips":["Stop the worker cleanly (via the CLI) before running uninstall","Keep CLAUDE_MEM_WORKER_PORT in settings accurate after any manual port change","After uninstall, verify no claude-mem process survives: ps aux | grep claude-mem"],"tags":["uninstall","worker","shutdown","timeout"],"backgroundTag":"graceful-shutdown-timeout","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}