A room whose ledger cannot be read is logged and left unloaded, not the server down; the server has tests of its own

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
Eric Wagoner
2026-09-29 12:13:11 -04:00
co-authored by Claude Opus 5.5
parent 2810076677
commit faa2845e70
5 changed files with 69 additions and 6 deletions
+10 -3
View File
@@ -30,7 +30,12 @@ export class Tallies<State, Input> {
const names = new Set<string>();
let firstStart = Infinity;
for (const id of this.store.roomIds()) {
const lines = this.store.read(id);
let lines: LedgerLine[];
try {
lines = this.store.read(id);
} catch {
continue; // an unreadable ledger is left out of the count, as its room is left unloaded
}
if (lines[0]?.t !== 'room') continue;
t.tablesOpened += 1;
const seats: { id: SeatId; name: string; bot: boolean }[] = [];
@@ -44,8 +49,10 @@ export class Tallies<State, Input> {
seats.push(line);
if (line.bot) hasBot = true;
else names.add(line.name.toLowerCase());
} else if (line.t === 'unseat') seats.splice(seats.findIndex((s) => s.id === line.id), 1);
else if (line.t === 'start') {
} else if (line.t === 'unseat') {
const i = seats.findIndex((s) => s.id === line.id);
if (i >= 0) seats.splice(i, 1);
} else if (line.t === 'start') {
t.gamesBegun += 1;
if (hasBot) t.gamesWithBot += 1;
if (lines[0].createdAt < firstStart) firstStart = lines[0].createdAt;