thedotmack/claude-mem · error · ServerClientError
Server failed
Error message
Server ${method} ${path} failed: ${message} What it means
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.
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.
Example fix
// before
const client = new ServerClient({ baseUrl: 'http://localhost:9999', apiKey, timeoutMs: 5000 });
// after
const client = new ServerClient({ baseUrl: process.env.CLAUDE_MEM_SERVER_URL ?? 'http://localhost:8765', apiKey, timeoutMs: 15000 });
// and ensure the server process is actually listening on that port Defensive patterns
Strategy: retry
Validate before calling
const url = new URL(baseUrl); // throws early on malformed baseUrl
Try / catch
try {
await client.recordEvent(event);
} catch (e) {
if (e instanceof ServerClientError && (e.code === 'transport' || e.code === 'timeout')) {
await retryWithBackoff(() => client.recordEvent(event), { retries: 3 });
} throw e;
} Prevention
- 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.
When it happens
Trigger: Server unreachable (connection refused), DNS failure, TLS error, or fetchWithTimeout exceeding this.timeoutMs — for any request method (GET/POST) to any /v1 path.
Common situations: 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.
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
- [claude-mem] Worker GET
- [claude-mem] Worker POST
- Failed to clear logs
- Failed to fetch logs
- OpenRouter API error
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/769c7ed13b6402b4.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/hooks/server-client.ts:381
const url = `${this.baseUrl}${path}`;
const init: RequestInit = {
method,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.apiKey}`,
},
};
if (body !== undefined) {
init.body = JSON.stringify(body);
}
let response: Response;
try {
response = await fetchWithTimeout(url, init, this.timeoutMs);
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
const isTimeout = /timed out|timeout/i.test(message);
throw new ServerClientError(
isTimeout ? 'timeout' : 'transport',
`Server ${method} ${path} failed: ${message}`,
{ cause: error },
);
}
if (!response.ok) {
const text = await response.text().catch(() => '');
throw new ServerClientError(
'http_error',
`Server ${method} ${path} returned ${response.status}: ${truncate(text, 200)}`,
{ status: response.status },
);
}
const text = await response.text();
if (!text || text.length === 0) {
// Endpoints we call always return JSON; a body-less success is unusualView on GitHub (pinned to d8bc9755e7)