{"record":{"id":"f785cdeb6a478270","repo":"davila7/claude-code-templates","slug":"failed-to-load-initial-data","errorCode":null,"errorMessage":"⚠️  Failed to load initial data:","messagePattern":"⚠️  Failed to load initial data:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli-tool/src/chats-mobile.js","lineNumber":1040,"sourceCode":"            \n            // Initialize snapshots for change detection\n            const snapshots = parsedMessages.map(msg => this.generateMessageSnapshot(msg));\n            this.conversationMessageSnapshots.set(conversation.id, snapshots);\n          } catch (error) {\n            // If we can't parse the conversation, set count to 0 and empty snapshots\n            this.conversationMessageCounts.set(conversation.id, 0);\n            this.conversationMessageSnapshots.set(conversation.id, []);\n          }\n        }\n        \n        console.log(chalk.green(`📂 Loaded ${this.data.conversations.length} conversations`));\n        console.log(chalk.gray(`📊 Initialized message counts for ${this.conversationMessageCounts.size} conversations`));\n      } else {\n        console.log(chalk.yellow('⚠️  No Claude Code data directory found'));\n        console.log(chalk.gray(`    Expected directory: ${claudeDataDir}`));\n      }\n    } catch (error) {\n      console.warn(chalk.yellow('⚠️  Failed to load initial data:', error.message));\n    }\n  }\n\n  /**\n   * Start the mobile chats server\n   */\n  async startServer() {\n    return new Promise(async (resolve) => {\n      this.httpServer = this.app.listen(this.port, async () => {\n        this.localUrl = `http://localhost:${this.port}`;\n        console.log(chalk.green(`📱 Chats Mobile server started at ${this.localUrl}`));\n        \n        // Initialize WebSocket server with HTTP server\n        try {\n          this.webSocketServer = new WebSocketServer(this.httpServer, {\n            port: this.port,\n            path: '/ws'\n          });","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/chats-mobile.js#L1022-L1058","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight the data dir with access check\nconst ok = await fs.access(claudeDataDir).then(() => true).catch(() => false);\nif (!ok) { console.warn(`No Claude Code data directory at ${claudeDataDir}`); /* start with empty state */ }","typeGuard":null,"tryCatchPattern":"try { await this.loadInitialData(); }\ncatch (error) {\n  console.warn('Failed to load initial data:', error.message);\n  // server still starts; data will populate via watcher events\n}","preventionTips":["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"],"tags":["chats-mobile","startup","file-io"],"backgroundTag":"startup-data-load-failed","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}