{"record":{"id":"6f9edd27d0eb07db","repo":"thedotmack/claude-mem","slug":"claude-mem-worker-post-path-failed-message","errorCode":null,"errorMessage":"[claude-mem] Worker POST ${path} failed: ${message}","messagePattern":"\\[claude-mem\\] Worker POST (.+?) failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/integrations/opencode-plugin/index.ts","lineNumber":119,"sourceCode":"}\n\nconst WORKER_BASE_URL = `http://${resolveWorkerHost()}:${resolveWorkerPort()}`;\nconst MAX_TOOL_RESPONSE_LENGTH = 1000;\n\nconst JSON_HEADERS: Record<string, string> = { \"Content-Type\": \"application/json\" };\n\nfunction workerPostFireAndForget(\n  path: string,\n  body: Record<string, unknown>,\n): void {\n  fetch(`${WORKER_BASE_URL}${path}`, {\n    method: \"POST\",\n    headers: JSON_HEADERS,\n    body: JSON.stringify(body),\n  }).catch((error: unknown) => {\n    const message = error instanceof Error ? error.message : String(error);\n    if (!message.includes(\"ECONNREFUSED\")) {\n      console.warn(`[claude-mem] Worker POST ${path} failed: ${message}`);\n    }\n  });\n}\n\nasync function workerGetText(path: string): Promise<string | null> {\n  try {\n    const response = await fetch(`${WORKER_BASE_URL}${path}`, { headers: JSON_HEADERS });\n    if (!response.ok) {\n      console.warn(`[claude-mem] Worker GET ${path} returned ${response.status}`);\n      return null;\n    }\n    return await response.text();\n  } catch (error: unknown) {\n    const message = error instanceof Error ? error.message : String(error);\n    if (!message.includes(\"ECONNREFUSED\")) {\n      console.warn(`[claude-mem] Worker GET ${path} failed: ${message}`);\n    }\n    return null;","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/integrations/opencode-plugin/index.ts#L101-L137","documentation":"The OpenCode plugin posts tool observations and session mappings fire-and-forget to the local claude-mem worker at http://CLAUDE_MEM_WORKER_HOST:CLAUDE_MEM_WORKER_PORT. This warning fires when the POST promise rejects with anything except ECONNREFUSED (which is suppressed because a not-yet-started worker is the normal case). Typical causes: connection reset mid-request, timeout, DNS failure on a custom host, or a non-worker process owning the port.","triggerScenarios":"workerPostFireAndForget() with paths like session-observation endpoints while the worker crashes/restarts mid-request, while CLAUDE_MEM_WORKER_HOST resolves to a name with no DNS record, or while another process holds the configured port and immediately destroys the socket. Note WORKER_BASE_URL is computed once at plugin module load, so a port change after OpenCode started also lands here.","commonSituations":"Worker daemon restarted or upgraded while an OpenCode session stayed open; CLAUDE_MEM_WORKER_PORT changed in settings.json but OpenCode was not restarted, so the plugin still targets the old port now held by something else; firewall rules when the worker host is set to a non-loopback address.","solutions":["Restart the worker (`npx claude-mem worker` or reinstall via `npx claude-mem install` so the service/daemon is re-registered).","Verify reachability with the same URL the plugin uses: `curl -i http://127.0.0.1:$CLAUDE_MEM_WORKER_PORT/` and check the worker answers.","Confirm CLAUDE_MEM_WORKER_PORT / CLAUDE_MEM_WORKER_HOST in ~/.claude-mem/settings.json match the running worker, then restart OpenCode so the plugin re-resolves WORKER_BASE_URL.","If a custom host is set, check DNS/firewall for that host or revert CLAUDE_MEM_WORKER_HOST to 127.0.0.1."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Health-check the worker before a session that depends on it:\nasync function workerUp(base: string): Promise<boolean> {\n  try {\n    const r = await fetch(`${base}/`, { signal: AbortSignal.timeout(1000) });\n    return r.ok || r.status < 500;\n  } catch { return false; }\n}\nif (!(await workerUp('http://127.0.0.1:3777'))) await startWorker();","typeGuard":null,"tryCatchPattern":"// Fire-and-forget pattern used by the plugin itself: attach .catch, filter the\n// expected ECONNREFUSED (worker not started yet), surface everything else:\nfetch(url, opts).catch((e: unknown) => {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (!msg.includes('ECONNREFUSED')) console.warn('[my-plugin] POST failed:', msg);\n});","preventionTips":["Register the worker as a service/daemon so it auto-starts before OpenCode.","Pin CLAUDE_MEM_WORKER_PORT/HOST explicitly in settings.json on multi-user machines (UID-derived defaults differ per user).","Restart OpenCode after changing worker host/port — the plugin resolves WORKER_BASE_URL once at load.","Keep plugin and worker on the same claude-mem version."],"tags":["network","worker","opencode-plugin","fire-and-forget","fetch"],"backgroundTag":"network-request-failed","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}