{"record":{"id":"6c20fd0d45712c6b","repo":"paperclipai/paperclip","slug":"another-restart-for-instance-instanceid-is-stil","errorCode":null,"errorMessage":"Another restart for instance ${instanceId} is still running. If no restart process is active, remove the stale lock at ${lockPath} and retry.","messagePattern":"Another restart for instance (.+?) is still running\\. If no restart process is active, remove the stale lock at (.+?) and retry\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/service.ts","lineNumber":97,"sourceCode":"      await fs.writeFile(lockPath, `${token}\\n`, { encoding: \"utf8\", mode: 0o600, flag: \"wx\" });\n      break;\n    } catch (error) {\n      if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n      try {\n        const existingToken = (await fs.readFile(lockPath, \"utf8\")).trim();\n        const ownerPid = Number.parseInt(existingToken.split(\":\", 1)[0] ?? \"\", 10);\n        if (Number.isInteger(ownerPid) && ownerPid > 0 && !isProcessAlive(ownerPid)) {\n          if ((await fs.readFile(lockPath, \"utf8\")).trim() === existingToken) {\n            await fs.rm(lockPath, { force: true });\n            continue;\n          }\n        }\n      } catch (readError) {\n        if ((readError as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n        throw readError;\n      }\n      if (Date.now() >= deadline) {\n        throw new Error(\n          `Another restart for instance ${instanceId} is still running. ` +\n          `If no restart process is active, remove the stale lock at ${lockPath} and retry.`,\n        );\n      }\n      await new Promise((resolve) => setTimeout(resolve, pollMs));\n    }\n  }\n\n  try {\n    return await callback();\n  } finally {\n    try {\n      if ((await fs.readFile(lockPath, \"utf8\")).trim() === token) {\n        await fs.rm(lockPath, { force: true });\n      }\n    } catch (error) {\n      if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n    }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/commands/service.ts#L79-L115","documentation":"withHotRestartLock uses an exclusive lockfile per instance; another live restart process holds it. A stale lock whose owner pid is dead is auto-removed, so seeing this means the owner is alive or the lock is manually stuck.","triggerScenarios":"Thrown at cli/src/commands/service.ts:97 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the running restart to finish; if none is active, remove the stale lock file and retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}