fix: prevent sendStartGameMsg from crashing server on client disconnect#3939
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe ChangesGame Messaging Robustness
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
The catch block in sendStartGameMsg() re-throws the error, which means a single client's WebSocket failure (e.g. disconnected during game start) propagates up and can crash the entire game server. The start() method calls sendStartGameMsg() in a forEach loop over all clients, so one bad client kills the game for everyone. Changes: - Added readyState check before sending - Replaced re-throw with structured error logging - A single client failure now logs the error and continues gracefully
c70d258 to
aa6f844
Compare
The catch block in sendStartGameMsg() re-throws the error, which means a single client's WebSocket failure (e.g. disconnected during game start) propagates up and can crash the entire game server. The start() method calls sendStartGameMsg() in a forEach loop over all clients, so one bad client kills the game for everyone.
Changes:
If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)
Description:
Describe the PR.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
barfires