Daeseon Yoo
Back to project
·Tech retro·4 min

Phase 2 — test coverage + observability (JWT auto-recovery, JSON logs, Sentry, Prometheus)

Phase 2 added 52 new tests (game engine, matchmaking) and the observability backbone — structured JSON logging, Sentry, and Prometheus /metrics — plus a client-side JWT 401 auto-recovery fix. Suite grew from 52 to 99 tests.

What

Phase 2 closed test gaps and stood up the observability layer. Five areas:

The JWT 401 bug

Symptom Jason kept hitting, even after clearing localStorage:

Invalid token: Signature has expired

Cause (verified from the log): the pgdata docker volume was being recreated during docker compose up --build, so the stored JWT referenced a player_id no longer present in the rebuilt DB. The server's reject-expired-tokens behavior is correct — the client just didn't know to re-auth.

Fix (web/src/lib/api.ts): apiFetch now catches 401, clears the stale token via logout(), creates a fresh guest session, and retries once. A guard skips the retry for the guest endpoint itself to avoid an infinite loop.

Notes

Results

Decisions

Commits