{"record":{"id":"de17c8a206297dd4","repo":"thedotmack/claude-mem","slug":"install-pre-overwrite-worker-shutdown-failed","errorCode":null,"errorMessage":"[install] Pre-overwrite worker shutdown failed: ${message}","messagePattern":"\\[install\\] Pre-overwrite worker shutdown failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/install.ts","lineNumber":2046,"sourceCode":"  {\n    if (needsMarketplace) {\n      const installPort = getSetting('CLAUDE_MEM_WORKER_PORT');\n      const shutdownSpinner = isInteractive ? p.spinner() : null;\n      shutdownSpinner?.start('Stopping running worker (so we can overwrite cleanly)…');\n      try {\n        const result = await shutdownWorkerAndWait(installPort, 10000);\n        const stopMessage = result.workerWasRunning ? 'Stopped running worker before overwrite.' : 'No worker running — proceeding.';\n        if (shutdownSpinner) {\n          shutdownSpinner.stop(stopMessage);\n        } else if (result.workerWasRunning) {\n          log.info('Stopped running worker before overwrite.');\n        }\n      } catch (error: unknown) {\n        const message = error instanceof Error ? error.message : String(error);\n        if (shutdownSpinner) {\n          shutdownSpinner.error(`Pre-overwrite worker shutdown failed: ${message}`);\n        } else {\n          console.warn('[install] Pre-overwrite worker shutdown failed:', message);\n        }\n      }\n    }\n\n    const tasks: TaskDescriptor[] = [\n      {\n        title: 'Caching plugin version',\n        task: async (message) => {\n          message(`Caching v${version}...`);\n          copyPluginToCache(version);\n          return `Plugin cached (v${version}) ${styleText('green', 'OK')}`;\n        },\n      },\n      {\n        title: 'Registering marketplace',\n        task: async () => {\n          registerMarketplace();\n          return `Marketplace registered ${styleText('green', 'OK')}`;","sourceCodeStart":2028,"sourceCodeEnd":2064,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/install.ts#L2028-L2064","documentation":"On reinstall, the installer first tries `shutdownWorkerAndWait(installPort, 10000)` so plugin files can be overwritten. If that shutdown throws (hung worker, shutdown endpoint error, or the 10s wait exceeded), the catch logs this warning and the overwrite proceeds anyway — the still-running worker keeps the old code until it next restarts.","triggerScenarios":"`npx claude-mem install` runs over an existing installation while the worker on the install port fails to acknowledge shutdown within 10 seconds or the shutdown request errors.","commonSituations":"Stale worker from a previous version, deadlocked worker process, another process squatting on the install port, or a slow machine exceeding the 10s budget.","solutions":["Stop the worker manually (kill the claude-mem worker process or free the install port), then re-run install.","Verify nothing else occupies the install port before reinstalling.","Re-run `npx claude-mem install` after the manual stop and confirm the new worker version afterwards.","If it recurs, restart the machine to clear orphaned processes."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import net from 'node:net';\n\nfunction portInUse(port: number): Promise<boolean> {\n  return new Promise((resolve) => {\n    const s = net.connect({ host: '127.0.0.1', port }, () => { s.destroy(); resolve(true); });\n    s.on('error', () => resolve(false));\n  });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stop the running worker before reinstalling.","Keep the install port free of unrelated processes.","After any install that shows this warning, restart the worker so it runs the new code."],"tags":["install","reinstall","worker-shutdown","timeout"],"backgroundTag":"service-shutdown-timeout","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}