{"record":{"id":"769c7ed13b6402b4","repo":"thedotmack/claude-mem","slug":"server-method-path-failed-message","errorCode":null,"errorMessage":"Server ${method} ${path} failed: ${message}","messagePattern":"Server (.+?) (.+?) failed: (.+?)","errorType":"exception","errorClass":"ServerClientError","httpStatus":null,"severity":"error","filePath":"src/services/hooks/server-client.ts","lineNumber":381,"sourceCode":"    const url = `${this.baseUrl}${path}`;\n    const init: RequestInit = {\n      method,\n      headers: {\n        'Content-Type': 'application/json',\n        Authorization: `Bearer ${this.apiKey}`,\n      },\n    };\n    if (body !== undefined) {\n      init.body = JSON.stringify(body);\n    }\n\n    let response: Response;\n    try {\n      response = await fetchWithTimeout(url, init, this.timeoutMs);\n    } catch (error: unknown) {\n      const message = error instanceof Error ? error.message : String(error);\n      const isTimeout = /timed out|timeout/i.test(message);\n      throw new ServerClientError(\n        isTimeout ? 'timeout' : 'transport',\n        `Server ${method} ${path} failed: ${message}`,\n        { cause: error },\n      );\n    }\n\n    if (!response.ok) {\n      const text = await response.text().catch(() => '');\n      throw new ServerClientError(\n        'http_error',\n        `Server ${method} ${path} returned ${response.status}: ${truncate(text, 200)}`,\n        { status: response.status },\n      );\n    }\n\n    const text = await response.text();\n    if (!text || text.length === 0) {\n      // Endpoints we call always return JSON; a body-less success is unusual","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/hooks/server-client.ts#L363-L399","documentation":"Thrown when fetch itself fails — the HTTP request never completed with a response. The original error's message is embedded and the code is 'transport', or 'timeout' if the failure message looks like a fetch timeout (fetchWithTimeout abort). The underlying error is attached as cause.","triggerScenarios":"Server unreachable (connection refused), DNS failure, TLS error, or fetchWithTimeout exceeding this.timeoutMs — for any request method (GET/POST) to any /v1 path.","commonSituations":"Server not running on the configured baseUrl/port, wrong host in CLAUDE_MEM_SERVER_URL, firewall/network outage in CI, or slow server exceeding the client timeout.","solutions":["Verify the server is running and reachable at the configured baseUrl (curl it).","Correct the base URL / port configuration for the ServerClient.","If the message indicates a timeout, increase timeoutMs or investigate slow server responses.","Inspect error.cause for the underlying network error; retry transient network failures with backoff."],"exampleFix":"// before\nconst client = new ServerClient({ baseUrl: 'http://localhost:9999', apiKey, timeoutMs: 5000 });\n\n// after\nconst client = new ServerClient({ baseUrl: process.env.CLAUDE_MEM_SERVER_URL ?? 'http://localhost:8765', apiKey, timeoutMs: 15000 });\n// and ensure the server process is actually listening on that port","handlingStrategy":"retry","validationCode":"const url = new URL(baseUrl); // throws early on malformed baseUrl\n","typeGuard":null,"tryCatchPattern":"try {\n  await client.recordEvent(event);\n} catch (e) {\n  if (e instanceof ServerClientError && (e.code === 'transport' || e.code === 'timeout')) {\n    await retryWithBackoff(() => client.recordEvent(event), { retries: 3 });\n  } throw e;\n}","preventionTips":["Health-check the server URL at startup before real traffic.","Set a timeoutMs appropriate for your network; increase for slow links.","Retry idempotent calls on transport/timeout codes with exponential backoff."],"tags":["network","http","timeout","client"],"backgroundTag":"http-request-failed","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}