thedotmack/claude-mem · warning

[claude-mem] Worker POST

Error message

[claude-mem] Worker POST ${path} failed: ${message}

What it means

workerPostFireAndForget sends fire-and-forget POSTs to the claude-mem worker; if the fetch rejects, it logs this warning unless the error is ECONNREFUSED (worker simply not running). It surfaces network/protocol failures on worker communication.

Solutions

  1. Start the claude-mem worker and verify it is listening at WORKER_BASE_URL
  2. Check WORKER_BASE_URL for typos in host/port
  3. Test connectivity: curl the worker endpoint path directly
  4. Inspect the logged message for the underlying cause (DNS vs TLS vs abort)

Example fix

// before
const WORKER_BASE_URL = "http://localhost:wrong-port";
// after
const WORKER_BASE_URL = "http://127.0.0.1:37777"; // match worker config
Defensive patterns

Strategy: retry

Validate before calling

const url = new URL(`${WORKER_BASE_URL}${path}`);
await fetch(url, { method: 'HEAD' }).then(r => { if (!r.ok) console.warn('worker unhealthy:', r.status); });

Type guard

function isNetworkError(e: unknown): e is TypeError {
  return e instanceof TypeError; // fetch rejects with TypeError on network failure
}

Try / catch

try {
  await fetch(url, { method: 'POST', body });
} catch (e) {
  if (!(e instanceof Error && e.message.includes('ECONNREFUSED'))) {
    console.warn('worker POST failed', e);
    // queue for retry
  }
}

Prevention

When it happens

Trigger: The fetch to `${WORKER_BASE_URL}${path}` rejects with a non-ECONNREFUSED error: DNS failure, TLS error, request aborted, invalid URL, or an unexpected TypeError from fetch.

Common situations: Worker URL misconfigured (wrong port/host); worker crashed mid-request; proxy/firewall interfering; WORKER_BASE_URL malformed so fetch throws immediately.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/6f9edd27d0eb07db. Report an issue: GitHub.

Appendix: source

Thrown at src/integrations/opencode-plugin/index.ts:127

const MAX_TOOL_RESPONSE_LENGTH = 1000;

const JSON_HEADERS: Record<string, string> = { "Content-Type": "application/json" };

function workerPostFireAndForget(
  path: string,
  body: Record<string, unknown>,
): void {
  fetch(`${WORKER_BASE_URL}${path}`, {
    method: "POST",
    headers: JSON_HEADERS,
    body: JSON.stringify({
      ...body,
      platformSource: normalizePlatformSource("opencode"),
    }),
  }).catch((error: unknown) => {
    const message = error instanceof Error ? error.message : String(error);
    if (!message.includes("ECONNREFUSED")) {
      console.warn(`[claude-mem] Worker POST ${path} failed: ${message}`);
    }
  });
}

async function workerGetText(path: string): Promise<string | null> {
  try {
    const response = await fetch(`${WORKER_BASE_URL}${path}`, { headers: JSON_HEADERS });
    if (!response.ok) {
      console.warn(`[claude-mem] Worker GET ${path} returned ${response.status}`);
      return null;
    }
    return await response.text();
  } catch (error: unknown) {
    const message = error instanceof Error ? error.message : String(error);
    if (!message.includes("ECONNREFUSED")) {
      console.warn(`[claude-mem] Worker GET ${path} failed: ${message}`);
    }
    return null;

View on GitHub (pinned to d8bc9755e7)