fix: add readyState check before endTurn broadcast#3879
fix: add readyState check before endTurn broadcast#3879berkelmali wants to merge 1 commit intoopenfrontio:mainfrom
Conversation
Guard ws.send() in endTurn() with a readyState === OPEN check to prevent sending to connections that have already closed.
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe pull request adds a readiness check to the ChangesWebSocket Readiness Validation
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~8 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 |
I don’t think this claim is accurate. In current if the real concern is “any send to a closed socket may crash or misbehave,” this PR is too narrow. Other sends remain unguarded. If we want this pattern consistently, a small |
Description:
Guard
ws.send()inendTurn()with areadyState === OPENcheck to prevent sending messages to WebSocket connections that have already closed.Without this guard, broadcasting to a client whose connection closed between ticks can throw an exception and crash the game loop.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
barfires