Maintenance sweep: docs, logging, production error fixes - #1
Open
Justrada wants to merge 1 commit into
Open
Conversation
Consolidates a parallel three-track maintenance pass (docs / logging / error sweep) into one change set. == Production error fixes (static audit; no log aggregation configured) == - usePartySocket: crypto.randomUUID is undefined in non-secure contexts (HTTP) and older Safari — both the happy path AND the catch fallback called it, so such clients threw and hung on the connecting spinner. Added a guarded randomId() fallback (mirrors partysocket's own guard). - gameLogic.triggerSuspicionEvent is now idempotent: re-triggering while an event is active no longer wipes verbs players already submitted (could happen when the GM nudged suspicion at the cap). +regression test. - StreamSetup.copy: navigator.clipboard.writeText rejection was unhandled (insecure context / no focus / denied) — produced an unhandled rejection and a false "Copied!". Now awaited; only flips on success. == Logging coverage (was: 1 console.error total) == - party/index.ts: added a structured log() helper ([CG room=...] event key=value, to the PartyKit log stream) and instrumented connection lifecycle, joins (+rejects), phase transitions, all rolls (the roll.play line carries result/target/outcome/modifier/chaos/suspicion), suspicion trigger/resolve, item use/give, verb submit, every GM action, play-again, and both error paths (bad JSON, handler throw). - Added requireGM() guard that logs reject.notGM instead of silently returning (replaces ~15 silent GM checks). - usePartySocket: client clog() for open/reconnect/close/socket-error/ bad-message/server-error. Added the previously-missing socket "error" listener. Nothing logged in render bodies or hot paths (VDO loudness, per-state messages) to avoid console spam. - Verified live: drove join/start-game through partykit dev and confirmed the expected lines (connect, join, reject.notGM, start-game) emit. == Documentation == - README: room codes are 4-char alphanumeric (not "4-letter"); documented the seat model (GM=seat 0, players 1-7) behind video+overlay; noted there is no combined dev/deploy script and how to tail server logs. - types.ts / gameLogic.ts: clarifying comments (CHAOS extremes + start, suspicion-6 fires the verb event). build + eslint clean; 23 logic assertions pass (incl. new idempotency test). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One-time parallelized maintenance sweep. Three concerns were investigated concurrently by separate sub-agents (documentation, logging coverage, production error audit); the resulting changes are consolidated here into a single branch.
🐛 Production error fixes
No error-monitoring/log-aggregation is configured and the Vercel CLI here is unauthenticated, so this was a static production-error audit (a live
partykit tailshowed no traffic, as expected). The codebase was already hardened recently, so the list is short and not padded — these are real:crypto.randomUUIDcrash on non-secure/older clients (usePartySocket.ts) —crypto.randomUUIDis undefined over plain HTTP and on older Safari; both the happy path and thecatchfallback used it, so affected clients threw and hung on the connecting spinner. Added a guardedrandomId()fallback. Production is HTTPS so the happy path holds today, but embedded webviews / HTTP proxies / old browsers were locked out.gameLogic.ts) —triggerSuspicionEventre-initialized the event every time it fired; nudging suspicion at the cap (or another failure while the modal was open) resetverbsto[], losing what players already submitted. Made it idempotent. + regression test.StreamSetup.tsx) —navigator.clipboard.writeTextrejects (no focus / insecure / denied); the rejection was unhandled and the button falsely showed "Copied!". Now awaited; only flips on success.📋 Logging coverage
Went from one
console.errorin the whole app to structured coverage of the critical paths:party/index.ts: alog()helper emitting[CG room=XXXX] event key=valueto the PartyKit log stream. Instruments connection lifecycle, joins (+rejects), phase transitions, all rolls (theroll.playline carries result/target/outcome/modifier/chaos/suspicion), suspicion trigger/resolve, item use/give, verb submit, every GM action, play-again, and both error paths (bad JSON + handler throw).requireGM()guard logsreject.notGMinstead of ~15 silent returns.usePartySocket.ts: clientclog()for open/reconnect/close/socket-error (listener was missing entirely)/bad-message/server-error.partykit devand confirmedconnect,join,reject.notGM,start-game,close.midgameall emit.📚 Documentation
types.ts/gameLogic.ts: clarifying comments (chaos extremes + start value; suspicion-6 fires the verb event).✅ Verification
next build✅ ·eslint src party✅ (0 problems) · 23 logic assertions pass (incl. new idempotency test) · logging confirmed emitting on a live dev server.🤖 Generated with Claude Code