thedotmack/claude-mem · info
Service initializing
Service initializing
Error message
Database is still initializing, please retry
What it means
The worker service gates all HTTP routes behind an initializationCompleteFlag middleware. Until database initialization finishes, any request is rejected with 503 and code 'Service initializing', instructing the client to retry.
Solutions
- Retry the request with backoff until initialization completes
- Wait for a readiness/health signal before sending real requests
- Check worker logs for DB init failures if the condition persists
Example fix
// before
fetch('http://127.0.0.1:37777/api/observations') // immediately after start
// after
await waitForWorkerReady('http://127.0.0.1:37777');
fetch('http://127.0.0.1:37777/api/observations'); Defensive patterns
Strategy: retry
Validate before calling
async function isWorkerReady(baseUrl: string) {
const r = await fetch(`${baseUrl}/health`);
return r.ok;
} Try / catch
async function withRetry<T>(fn: () => Promise<T>, attempts = 10): Promise<T> {
for (let i = 0; i < attempts; i++) {
try { return await fn(); }
catch (e) {
if (i === attempts - 1) throw e;
await new Promise(r => setTimeout(r, 500 * (i + 1)));
}
}
throw new Error('unreachable');
} Prevention
- Gate clients on a readiness/health endpoint before real calls
- Use exponential backoff for all early-startup requests
- Monitor DB init logs; alert if 503s persist beyond expected startup
When it happens
Trigger: Any HTTP request to the worker during the window between process start and DB init completion; requesting immediately after a worker restart while the database is being opened/migrated.
Common situations: Health checks or UI hitting the worker right after restart; orchestrators starting clients and worker simultaneously; slow DB init on cold storage.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Cloud sync flush failed; unsynced rows remain queued
- sync hub pull
- Anthropic API error
- Auto-reprime failed for corpus
- BadRequest
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/3a2c302d20c97063.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/worker-service.ts:400
this.server.app.use(['/api', '/v1'], async (req, res, next) => {
if (
req.path === '/chroma/status' ||
req.path === '/health' ||
req.path === '/readiness' ||
req.path === '/version' ||
req.path === '/settings/dependency-health'
) {
next();
return;
}
if (this.initializationCompleteFlag) {
next();
return;
}
logger.debug('WORKER', `Request to ${req.method} ${req.path} rejected — DB not initialized`);
res.status(503).json({
error: 'Service initializing',
message: 'Database is still initializing, please retry'
});
return;
});
this.server.registerRoutes(new ViewerRoutes(this.sseBroadcaster, this.dbManager, this.sessionManager));
const sessionRoutes = new SessionRoutes(this.sessionManager, this.dbManager, this.sdkAgent, this.geminiAgent, this.openRouterAgent, this.sessionEventBroadcaster, this, this.completionHandler);
this.server.registerRoutes(sessionRoutes);
attachIngestGeneratorStarter((sessionDbId, source) =>
sessionRoutes.ensureGeneratorRunning(sessionDbId, source),
);
this.server.registerRoutes(new DataRoutes(this.paginationHelper, this.dbManager, this.sessionManager, this.sseBroadcaster, this, this.startTime));
this.server.registerRoutes(new SettingsRoutes(this.settingsManager));
this.server.registerRoutes(new LogsRoutes());
this.server.registerRoutes(new MemoryRoutes(this.dbManager, 'claude-mem'));
this.server.registerRoutes(new ServerV1Routes({
getDatabase: () => this.dbManager.getConnection(),View on GitHub (pinned to d8bc9755e7)