Skip to content

fix(events): isolate scoreEvents listener failures to prevent aborting binary feed broadcast and cron (closes #931) - #935

Open
mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/score-events-listener-isolation
Open

mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/score-events-listener-isolation

Conversation

@mopxam-art

Copy link
Copy Markdown

Summary

Isolates scoreEvents listener execution during score updates to prevent throwing subscribers from aborting the binary feed broadcast or failing the score-update cron:

  • Introduced emitScoreUpdateSafely in src/lib/events.ts to dispatch SCORE_UPDATE_EVENT with per-listener try/catch isolation and asynchronous promise rejection handling.
  • Wrapped score event dispatch in broadcastScoreUpdate (src/lib/websocket.ts) within a defensive try/catch block so exceptions never bypass binary WebSocket frame distribution.
  • Re-exported ERROR_RATE_LIMIT_WINDOW_MS in src/lib/error-limiter.ts.

Testing & Verification

  • Added comprehensive unit test suite in src/__tests__/broadcastScoreEventsIsolation.test.ts (111 tests) covering boundary payloads, throwing listener combinatorics, async rejections, subscriber mutations during dispatch, and memory leak absence.
  • Verified all 123 test suites pass (npm test - 1,530 tests green).
  • Clean tsc --noEmit and npm run lint (0 errors).
  • Clean production build (npm run build).

Closes #931

This branch has not been deployed

No deployments
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.

scoreEvents.emit is called without a try/catch, so a throwing listener propagates into the score-update cron

1 participant