{"record":{"id":"c45ad6a21c9f1cae","repo":"thedotmack/claude-mem","slug":"failed-to-trigger-processing-res-status","errorCode":null,"errorMessage":"Failed to trigger processing: ${res.status}","messagePattern":"Failed to trigger processing: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/check-pending-queue.ts","lineNumber":101,"sourceCode":"  );\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>;\n}\n\nasync function prompt(question: string): Promise<string> {\n  if (!process.stdin.isTTY) {\n    console.log(question + '(no TTY, use --process flag for non-interactive mode)');\n    return 'n';\n  }\n\n  return new Promise((resolve) => {\n    process.stdout.write(question);\n    process.stdin.setRawMode(false);\n    process.stdin.resume();\n    process.stdin.once('data', (data) => {\n      process.stdin.pause();\n      resolve(data.toString().trim());\n    });","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/scripts/check-pending-queue.ts#L83-L119","documentation":"triggerProcessing POSTs an empty body to /api/processing and throws on a non-2xx response. The endpoint starts/reports an asynchronous processing run. A non-OK status means the worker accepted the connection but refused to start processing — typically 409 when already processing, 500 on an internal error, or 404 if the route is absent.","triggerScenarios":"POSTing /api/processing while the worker is already processing (possible 409). Worker build predates the route (404). Handler exception during processing kickoff (500). Empty JSON body rejected by stricter validation (400).","commonSituations":"Running the script twice in quick succession. Plugin/worker version skew. Worker mid-restart when the POST lands.","solutions":["Run GET /api/processing-status first (the script does) — if isProcessing is already true, you don't need to POST.","curl -i -X POST http://$WORKER_URL/api/processing -H 'Content-Type: application/json' -d '{}' and read the status/body to distinguish 404/409/500.","Rebuild/restart the worker if the route is missing (404).","If 500, inspect worker logs for the kickoff-time exception (often a DB or Chroma init problem)."],"exampleFix":"// before — only status code in the message\nif (!res.ok) throw new Error(`Failed to trigger processing: ${res.status}`);\n\n// after — surface the response body and treat 409 (already processing) as non-fatal\nif (!res.ok) {\n  const detail = await res.text().catch(() => '<no body>');\n  if (res.status === 409) { console.log('Worker already processing — nothing to do.'); return; }\n  throw new Error(`Failed to trigger processing: ${res.status} — ${detail}`);\n}","handlingStrategy":"try-catch","validationCode":"// Only trigger when not already processing, to avoid 409-style failures:\nconst status = await getProcessingStatus();\nif (status.isProcessing || status.queueDepth === 0) {\n  console.log('Nothing to do:', status);\n  process.exit(0);\n}","typeGuard":"function isSetProcessingResponse(obj: unknown): obj is { status: string; isProcessing: boolean; queueDepth: number; activeSessions: number } {\n  return typeof obj === 'object' && obj !== null\n    && typeof (obj as any).status === 'string'\n    && typeof (obj as any).queueDepth === 'number';\n}","tryCatchPattern":"try {\n  const result = await triggerProcessing();\n  console.log('Triggered:', result);\n} catch (err) {\n  const msg = err instanceof Error ? err.message : String(err);\n  if (msg.includes(' 409')) { console.log('Already processing — no action taken.'); process.exit(0); }\n  console.error('Failed to trigger processing:', msg);\n  process.exit(1);\n}","preventionTips":["Call /api/processing-status first; skip the POST if already processing.","Don't run the script concurrently from multiple shells against one worker.","Keep plugin and worker versions aligned so the POST route exists."],"tags":["network","worker","http","queue-script","processing"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}