{"record":{"id":"023c67b1bcadb5a6","repo":"paperclipai/paperclip","slug":"request-failed-response-status","errorCode":null,"errorMessage":"Request failed: ${response.status}","messagePattern":"Request failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/src/client/board-auth.ts","lineNumber":171,"sourceCode":"  if (init?.body !== undefined && !headers.has(\"content-type\")) {\n    headers.set(\"content-type\", \"application/json\");\n  }\n  if (!headers.has(\"accept\")) {\n    headers.set(\"accept\", \"application/json\");\n  }\n\n  const response = await fetch(url, {\n    ...init,\n    headers,\n  });\n\n  if (!response.ok) {\n    const body = await response.json().catch(() => null);\n    const message =\n      body && typeof body === \"object\" && typeof (body as { error?: unknown }).error === \"string\"\n        ? (body as { error: string }).error\n        : `Request failed: ${response.status}`;\n    throw new Error(message);\n  }\n\n  return response.json() as Promise<T>;\n}\n\nexport async function openUrl(url: string): Promise<boolean> {\n  const { command, args } =\n    process.platform === \"darwin\"\n      ? { command: \"open\", args: [url] }\n      : process.platform === \"win32\"\n        ? { command: \"cmd\", args: [\"/c\", \"start\", \"\", url] }\n        : { command: \"xdg-open\", args: [url] };\n\n  return new Promise<boolean>((resolve) => {\n    let child: ChildProcess;\n    try {\n      child = spawn(command, args, { detached: true, stdio: \"ignore\" });\n    } catch {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/client/board-auth.ts#L153-L189","documentation":"A startup warning (logger.warn) from Paperclip's embedded-PostgreSQL bootstrap in server/src/index.ts:431, not a thrown error. When DATABASE_URL is unset, the server resolves the embedded data dir (config.embeddedPostgresDataDir) and reads its postmaster.pid: if the first line parses to a positive integer pid and that pid is alive (checked with process.kill(pid, 0)), another PostgreSQL postmaster already owns this cluster. The server deliberately skips init/start and attaches to the existing process instead of launching a second postmaster against the same data directory (which would corrupt it).","triggerScenarios":"Running `pnpm dev` (or any server start without DATABASE_URL) while a previous Paperclip server process or its orphaned embedded postgres child is still alive and using the same embeddedPostgresDataDir; e.g. the API server was killed but the postgres child survived, or a second checkout/worktree was started with the default data dir and port 54329.","commonSituations":"Dev loop where Ctrl-C on the server leaves the embedded postgres child running; two worktrees or two terminals sharing the default embedded data dir; CI runners that reuse a persisted data dir between jobs; a manually started postgres pointed at the same data directory.","solutions":["If a second server against the same DB is intentional, no action is needed - the server reuses the running postgres; note the pid and port from the message.","Otherwise stop the leftover postgres: verify with `ps -p <pid> -o comm=` then `kill <pid>` (or `lsof -ti :54329 | xargs kill`), and restart the server so it manages the lifecycle itself.","For parallel instances, give each its own data dir and port via config database.embeddedPostgresDataDir / database.embeddedPostgresPort, or set DATABASE_URL to an external postgres.","For a clean-slate dev cluster, stop all processes using the data dir, then delete the embedded data dir so the next start re-runs initdb (migrations re-apply automatically on first run)."],"exampleFix":"// before: two dev servers share the default embedded data dir\n// second start logs: \"Embedded PostgreSQL already running; reusing existing process (pid=1234, port=54329)\"\n\n// after (paperclip.config.json for the second instance): dedicated data dir + port\n{\n  \"database\": {\n    \"embeddedPostgresDataDir\": \"~/.paperclip/embedded-postgres-2\",\n    \"embeddedPostgresPort\": 54330\n  }\n}","handlingStrategy":"validation","validationCode":"import { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst isPidAlive = (pid: number): boolean => {\n  try { process.kill(pid, 0); return true; } catch { return false; }\n};\n\n// Run before starting a second server against the same data dir\nexport function embeddedPostgresRunning(dataDir: string): number | null {\n  const pidFile = resolve(dataDir, \"postmaster.pid\");\n  if (!existsSync(pidFile)) return null;\n  const pidLine = readFileSync(pidFile, \"utf8\").split(\"\\n\")[0]?.trim();\n  const pid = Number(pidLine);\n  return Number.isInteger(pid) && pid > 0 && isPidAlive(pid) ? pid : null;\n}","typeGuard":"function isEmbeddedPostgresLive(dataDir: string): boolean {\n  const pid = embeddedPostgresRunning(dataDir); // helper above\n  return typeof pid === \"number\"; // true => a second start will reuse it\n}","tryCatchPattern":null,"preventionTips":["Shut the dev server down cleanly so the embedded postgres child stops with it; verify with `lsof -ti :54329` before starting another instance.","Give each concurrent instance (worktrees, CI jobs) its own database.embeddedPostgresDataDir and embeddedPostgresPort.","Treat the 'already running; reusing' message as expected reuse, but confirm the logged pid is a postgres process (`ps -p <pid> -o comm=`) before relying on it."],"tags":["embedded-postgres","postmaster-pid","process-reuse","dev-startup"],"backgroundTag":"process-already-running","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"}