thedotmack/claude-mem · warning

[install] Pre-overwrite worker shutdown failed: ${message}

Error message

[install] Pre-overwrite worker shutdown failed: ${message}

What it means

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.

Source

Thrown at src/npx-cli/commands/install.ts:2046

  {
    if (needsMarketplace) {
      const installPort = getSetting('CLAUDE_MEM_WORKER_PORT');
      const shutdownSpinner = isInteractive ? p.spinner() : null;
      shutdownSpinner?.start('Stopping running worker (so we can overwrite cleanly)…');
      try {
        const result = await shutdownWorkerAndWait(installPort, 10000);
        const stopMessage = result.workerWasRunning ? 'Stopped running worker before overwrite.' : 'No worker running — proceeding.';
        if (shutdownSpinner) {
          shutdownSpinner.stop(stopMessage);
        } else if (result.workerWasRunning) {
          log.info('Stopped running worker before overwrite.');
        }
      } catch (error: unknown) {
        const message = error instanceof Error ? error.message : String(error);
        if (shutdownSpinner) {
          shutdownSpinner.error(`Pre-overwrite worker shutdown failed: ${message}`);
        } else {
          console.warn('[install] Pre-overwrite worker shutdown failed:', message);
        }
      }
    }

    const tasks: TaskDescriptor[] = [
      {
        title: 'Caching plugin version',
        task: async (message) => {
          message(`Caching v${version}...`);
          copyPluginToCache(version);
          return `Plugin cached (v${version}) ${styleText('green', 'OK')}`;
        },
      },
      {
        title: 'Registering marketplace',
        task: async () => {
          registerMarketplace();
          return `Marketplace registered ${styleText('green', 'OK')}`;

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Stop the worker manually (kill the claude-mem worker process or free the install port), then re-run install.
  2. Verify nothing else occupies the install port before reinstalling.
  3. Re-run `npx claude-mem install` after the manual stop and confirm the new worker version afterwards.
  4. If it recurs, restart the machine to clear orphaned processes.
Defensive patterns

Strategy: retry

Validate before calling

import net from 'node:net';

function portInUse(port: number): Promise<boolean> {
  return new Promise((resolve) => {
    const s = net.connect({ host: '127.0.0.1', port }, () => { s.destroy(); resolve(true); });
    s.on('error', () => resolve(false));
  });
}

Prevention

When it happens

Trigger: `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.

Common situations: Stale worker from a previous version, deadlocked worker process, another process squatting on the install port, or a slow machine exceeding the 10s budget.

Related errors


AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20). Data as JSON: /api/errors/de17c8a206297dd4. Report an issue: GitHub.