davila7/claude-code-templates · warning
⚠️ Failed to load initial data:
Error message
⚠️ Failed to load initial data:
What it means
ChatsMobile initial data loading caught an error while scanning the Claude Code data directory (conversation list, message counts). The server still starts, but starts with empty data.
Source
Thrown at cli-tool/src/chats-mobile.js:1040
// Initialize snapshots for change detection
const snapshots = parsedMessages.map(msg => this.generateMessageSnapshot(msg));
this.conversationMessageSnapshots.set(conversation.id, snapshots);
} catch (error) {
// If we can't parse the conversation, set count to 0 and empty snapshots
this.conversationMessageCounts.set(conversation.id, 0);
this.conversationMessageSnapshots.set(conversation.id, []);
}
}
console.log(chalk.green(`📂 Loaded ${this.data.conversations.length} conversations`));
console.log(chalk.gray(`📊 Initialized message counts for ${this.conversationMessageCounts.size} conversations`));
} else {
console.log(chalk.yellow('⚠️ No Claude Code data directory found'));
console.log(chalk.gray(` Expected directory: ${claudeDataDir}`));
}
} catch (error) {
console.warn(chalk.yellow('⚠️ Failed to load initial data:', error.message));
}
}
/**
* Start the mobile chats server
*/
async startServer() {
return new Promise(async (resolve) => {
this.httpServer = this.app.listen(this.port, async () => {
this.localUrl = `http://localhost:${this.port}`;
console.log(chalk.green(`📱 Chats Mobile server started at ${this.localUrl}`));
// Initialize WebSocket server with HTTP server
try {
this.webSocketServer = new WebSocketServer(this.httpServer, {
port: this.port,
path: '/ws'
});View on GitHub (pinned to a0851ed10c)
Solutions
- Confirm the server runs as the user owning ~/.claude
- Check readability: ls -la ~/.claude/projects | head
- Look at the error.message printed right after the warning to pinpoint the failing operation
- Increase ulimit -n for large project counts
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight the data dir with access check
const ok = await fs.access(claudeDataDir).then(() => true).catch(() => false);
if (!ok) { console.warn(`No Claude Code data directory at ${claudeDataDir}`); /* start with empty state */ } Try / catch
try { await this.loadInitialData(); }
catch (error) {
console.warn('Failed to load initial data:', error.message);
// server still starts; data will populate via watcher events
} Prevention
- Run the mobile chats server as the user who owns ~/.claude
- Verify CLAUDE_CONFIG_DIR / HOME are correct in the launching shell
- Raise ulimit -n when many projects exist
When it happens
Trigger: Startup scan of ~/.claude/projects failing — directory unreadable (EACCES/ENOENT despite the earlier existence check), EMFILE on large project counts, or JSON parse of a malformed index throwing outside a guarded path.
Common situations: Wrong CLAUDE_CONFIG_DIR/home (dir check passed but subpaths fail); permissions from running under a different user (sudo); network-mounted home with flaky reads.
Related errors
- Failed to update states
- Internal server error
- Conversation not found
- Failed to export session
- Warning: Could not extract project from conversation ${fileP
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/f785cdeb6a478270.
Report an issue: GitHub.