Skip to content

Debug tracing: alarm, duel and chat logs, daily room counters, logs script - #42

Merged
Finesssee merged 4 commits into
mainfrom
feat/debug-tracing
Oct 20, 2026
Merged

Finesssee merged 4 commits into
mainfrom
feat/debug-tracing

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

What changes for the owner

  • Alarms, bot commands, the duel lifecycle and chat delivery now write traces. Each trace is one JSON line in Workers Logs (free, kept 3 days). The room also keeps a capped tail per source in error_log. Busy sources (alarm, duel, chat) keep 200 rows and store at most 300 a day, so traces never push real errors out.
  • Each room keeps one counters row per UTC day: requests, websocket messages, alarms (and idle alarms), SQLite rows the tracker wrote, bot sent / failed / held, EventSub kinds, event types and log lines per source. It logs a warning at 25,000 and 50,000 requests plus alarms a day, and on an alarm burst (20 alarms in a row under a second apart, the loop fixed in Stop the room alarm loop after a rematch lock expires #41).
  • The owner page has Alarms, Duels and Chat delivery log filters and a "Room counters by day" table, backed by GET /api/dev/stats.
  • node scripts/logs.ts --mode test --channel nesszers reads Workers Logs from a terminal (docs/LIVE_FIX.md).

How counters reach SQLite

The room counts in memory. It saves after every alarm, on each read, after a request once 10 s have passed since the last save, and at least every 30 s while busy. A room that hibernates loses at most the last 10 s of request counts. During an alarm burst, an alarm saves like a request (at most every 10 s), so a runaway alarm loop can't double its own row writes. That last rule came from a security review of 491663d.

Evidence

  • bun run check passes, 411 of 411. The new burst test fails when the burst rule is removed (checked by reverting that one condition).
  • Staging (491663d) showed duel, alarm and chat traces and counters for requests, duel lines, commands and every event_* type after a bot duel on nesszers. Before 491663d the counters lost counts when the room went idle.
  • tests/dev-ui.ts passes with the new counters table at 390 px.
  • bun run test:ui fails at tests/ui.ts:1322 (mod page rules tab, "Save new version" stays disabled after typing a max HP). It fails the same way on main, so it predates this branch.

…cript

Every trace prints one JSON line to Workers Logs; the room keeps a capped
per-source tail in error_log and one counters row per UTC day (flushed every
5 minutes). Owner page gains Alarms, Duels and Chat delivery filters and a
counters-by-day table; scripts/logs.ts reads Workers Logs from a terminal.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: nesszer/pixfray/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46f79175-a123-4eaf-bd27-d437794998fa
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee
Finesssee merged commit b2796d4 into main Oct 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant