{"record":{"id":"019ec6b31a1f3245","repo":"thedotmack/claude-mem","slug":"failed-to-get-processing-status-res-status","errorCode":null,"errorMessage":"Failed to get processing status: ${res.status}","messagePattern":"Failed to get processing status: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/check-pending-queue.ts","lineNumber":85,"sourceCode":"    const res = await fetchWithTimeout(\n      `${WORKER_URL}/api/health`,\n      undefined,\n      'Health check did not respond',\n    );\n    return res.ok;\n  } catch {\n    return false;\n  }\n}\n\nasync function getProcessingStatus(): Promise<ProcessingStatusResponse> {\n  const res = await fetchWithTimeout(\n    `${WORKER_URL}/api/processing-status`,\n    undefined,\n    'Failed to get processing status',\n  );\n  if (!res.ok) {\n    throw new Error(`Failed to get processing status: ${res.status}`);\n  }\n  return res.json() as Promise<ProcessingStatusResponse>;\n}\n\nasync function triggerProcessing(): Promise<SetProcessingResponse> {\n  const res = await fetchWithTimeout(\n    `${WORKER_URL}/api/processing`,\n    {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify({})\n    },\n    'Failed to trigger processing',\n  );\n  if (!res.ok) {\n    throw new Error(`Failed to trigger processing: ${res.status}`);\n  }\n  return res.json() as Promise<SetProcessingResponse>;","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/scripts/check-pending-queue.ts#L67-L103","documentation":"getProcessingStatus fetches GET /api/processing-status and throws if the response is not 2xx. The worker uses this endpoint to report {isProcessing, queueDepth}. A non-OK status means the worker is up (it answered) but rejected the request — most often a transient 500 from an unhandled handler exception or a 404 if the route isn't registered.","triggerScenarios":"Worker running an older build without /api/processing-status (404). Handler throws on a malformed internal state (500). Route moved/renamed in a worker version newer than the script expects.","commonSituations":"Plugin/worker version skew after a partial upgrade. Worker started from a stale build directory. An exception in the worker's processing-status handler (e.g. querying a not-yet-initialised DB).","solutions":["curl -i http://$WORKER_URL/api/processing-status and read the status/body — 404 means the route is missing (rebuild worker), 500 means an internal error (check worker logs).","Rebuild and restart the worker so its routes match this version of the script: npm run build-and-sync / npm run worker:start.","If the body reveals a DB/path error, fix the underlying worker issue (the script is correct).","Retry once after a worker restart — transient 500s on cold start clear up."],"exampleFix":"// before — throws on any non-2xx, message only carries the status code\nif (!res.ok) throw new Error(`Failed to get processing status: ${res.status}`);\n\n// after — include the body so the cause is visible without a separate curl\nif (!res.ok) {\n  const detail = await res.text().catch(() => '<no body>');\n  throw new Error(`Failed to get processing status: ${res.status} — ${detail}`);\n}","handlingStrategy":"try-catch","validationCode":"// Reachability + version check before relying on the endpoint:\nasync function workerHasProcessingStatus(host: string, port: string): Promise<boolean> {\n  try {\n    const res = await fetch(`http://${host}:${port}/api/processing-status`);\n    return res.ok;\n  } catch { return false; }\n}","typeGuard":"function isProcessingStatus(obj: unknown): obj is { isProcessing: boolean; queueDepth: number } {\n  return typeof obj === 'object' && obj !== null\n    && typeof (obj as any).isProcessing === 'boolean'\n    && typeof (obj as any).queueDepth === 'number';\n}","tryCatchPattern":"try {\n  const status = await getProcessingStatus();\n  // ...\n} catch (err) {\n  console.error('Could not read processing status:', err instanceof Error ? err.message : err);\n  // hint user to rebuild/restart worker; exit non-zero so CI is honest\n  process.exit(1);\n}","preventionTips":["Keep plugin/worker versions in sync so /api/processing-status always exists.","Check worker health (the script does this first) before calling status endpoints.","Include response body in thrown errors to speed diagnosis (see exampleFix)."],"tags":["network","worker","http","queue-script","processing-status"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}