{"record":{"id":"731be39973246857","repo":"thedotmack/claude-mem","slug":"cannot-lazy-spawn-worker-worker-service-cjs-not-f","errorCode":null,"errorMessage":"Cannot lazy-spawn worker: worker-service.cjs not found in plugin/scripts","messagePattern":"Cannot lazy-spawn worker: worker-service\\.cjs not found in plugin/scripts","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/shared/worker-utils.ts","lineNumber":557,"sourceCode":"        pid: stalePidInfo.pid,\n        port: getWorkerPort(),\n      });\n      return false;\n    }\n    // The killed worker's PID file is left behind; the successor's boot\n    // removes it (validateWorkerPidFile returns 'stale' for a dead pid).\n    // Fall through to (re)spawn + readiness wait below.\n  }\n\n  const runtimePath = resolveWorkerRuntimePath();\n  const scriptPath = resolvedScript?.scriptPath ?? null;\n\n  if (!runtimePath) {\n    logger.warn('SYSTEM', 'Cannot lazy-spawn worker: Bun runtime not found on PATH');\n    return false;\n  }\n  if (!scriptPath) {\n    logger.warn('SYSTEM', 'Cannot lazy-spawn worker: worker-service.cjs not found in plugin/scripts');\n    return false;\n  }\n\n  // Spawn gate (worker-spawn-gate.ts): only ONE gated launcher — hook, MCP\n  // server, or the CLI restart fallback — may spawn at a time. (The dying\n  // worker's restart handoff in worker-shutdown.ts is deliberately NOT gated:\n  // it is the spawner for CLI-initiated restarts. Hook version recycles never\n  // trigger it — they SIGKILL the stale worker and spawn here.)\n  // Losing the lock never fails the hook; the loser skips its spawn and waits\n  // for the winner's worker on the existing port/readiness waits below. The\n  // winner holds the lock through the port-open wait (the spawn isn't \"done\"\n  // until the worker owns the port) and releases in finally on every exit\n  // path.\n  const spawnLockHeld = acquireSpawnLock();\n  try {\n    if (spawnLockHeld) {\n      logger.info('SYSTEM', 'Worker not running — lazy-spawning', { runtimePath, scriptPath });\n","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/shared/worker-utils.ts#L539-L575","documentation":"Lazy-spawn resolved the Bun runtime but resolvedScript.scriptPath is null — worker-service.cjs was not found under plugin/scripts for the current installation. The spawn aborts (returns false) and the hook event degrades, since there is no worker binary to launch.","triggerScenarios":"The plugin install is incomplete: build artifacts never synced, scripts directory missing after an in-place upgrade, or version resolution unable to locate worker-service.cjs for the resolved plugin version.","commonSituations":"Cloning the repo without running the build; a partial plugin update leaving plugin/scripts empty; marketplace sync deleting files mid-update.","solutions":["Run npm run build-and-sync in the claude-mem checkout — it rebuilds and syncs plugin scripts to the installed location.","Verify plugin/scripts/worker-service.cjs exists in the installed plugin (~/.claude/plugins/marketplaces/thedotmack/…).","If the marketplace copy is broken, reinstall the plugin from source."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!existsSync(path.join(pluginDir, 'scripts', 'worker-service.cjs'))) {\n  // run the build before hooks try to lazy-spawn\n  failEarlyWithHint('Run npm run build-and-sync');\n}","typeGuard":"const hasWorkerScript = (resolved: { scriptPath: string | null } | null): resolved is { scriptPath: string } =>\n  resolved?.scriptPath != null;","tryCatchPattern":null,"preventionTips":["Always run npm run build-and-sync after cloning or upgrading the repo.","Verify plugin/scripts/worker-service.cjs exists in the installed plugin directory.","Treat a missing worker-service.cjs as a broken install — reinstall rather than retrying hooks."],"tags":["worker","missing-artifact","plugin-install","claude-mem"],"backgroundTag":"missing-build-artifact","analyzedSha":"8bc631a71a487424b866756e43a6efa4574cc66b","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}