davila7/claude-code-templates · error

Failed to load sessions

Error message

Failed to load sessions

What it means

HTTP 500 from the teams dashboard GET /api/sessions when building the session list throws — typically a failure while reading/parsing ~/.claude/teams session JSONL files into this.sessions.

Source

Thrown at cli-tool/src/teams-dashboard.js:657

    this.app.get('/api/sessions', async (req, res) => {
      try {
        this.sessions = await this.discoverTeamSessions();
        res.json({
          sessions: this.sessions.map(s => ({
            id: s.id,
            projectName: s.projectName,
            agentCount: s.agentCount,
            startTime: s.startTime,
            endTime: s.endTime,
            duration: s.duration,
            gitBranch: s.gitBranch,
            teammateNames: s.teammateNames
          })),
          count: this.sessions.length,
          timestamp: new Date().toISOString()
        });
      } catch (error) {
        res.status(500).json({ error: 'Failed to load sessions' });
      }
    });

    // Global summary stats
    this.app.get('/api/summary', async (req, res) => {
      try {
        res.json({
          totalSessions: this.sessions.length,
          totalAgents: this.sessions.reduce((sum, s) => sum + s.agentCount, 0),
          timestamp: new Date().toISOString()
        });
      } catch (error) {
        res.status(500).json({ error: 'Failed to load summary' });
      }
    });

    // Full session detail (triggers parse)
    this.app.get('/api/sessions/:id', async (req, res) => {

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Check the thrown error (add a console.error/log of the exception)
  2. Inspect ~/.claude/teams session files for corruption and remove/repair them
  3. Fix read permissions on the sessions directory

Example fix

// before
} catch (error) {
  res.status(500).json({ error: 'Failed to load sessions' });
}
// after
} catch (error) {
  console.error('Failed to load sessions:', error);
  res.status(500).json({ error: 'Failed to load sessions', detail: String(error) });
}
Defensive patterns

Strategy: try-catch

Try / catch

try { const r = await fetch('/api/sessions'); if (!r.ok) throw new Error((await r.json()).error); } catch (e) { showError(e); }

Prevention

When it happens

Trigger: GET /api/sessions when session discovery hits an unreadable file, malformed JSONL, or a missing teams data directory.

Common situations: Corrupt session log files from a crashed run; permissions on the Claude data dir; dashboard started with a changed HOME.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/16b0aaafb5351dee. Report an issue: GitHub.