fix(realtime): prevent INVALID_STATE_ERROR crash in heartbeat#110
fix(realtime): prevent INVALID_STATE_ERROR crash in heartbeat#110Shivay-98 wants to merge 1 commit into
Conversation
Use clearInterval instead of clearTimeout when resetting the heartbeat timer, and guard socket.send() with a readyState check so pings are only sent on an open WebSocket. Fixes appwrite#101 Co-authored-by: Cursor <cursoragent@cursor.com>
|
This library is auto-generated by the Appwrite SDK Generator, and does not accept pull requests directly. To learn more about how you can help us improve this SDK, please check the contributing guide. |
Greptile SummaryThis PR fixes a two-part heartbeat bug in
Confidence Score: 4/5The change is a targeted, correct bug fix with no regressions introduced to the happy path. Both fixes ( No files require special attention; Important Files Changed
|
Summary
Fixes #101
clearTimeoutwithclearIntervalwhen resetting the Realtime heartbeat timer (it was created withsetInterval, so previous intervals were never cleared and stacked on every reconnect)socket.send()with areadyState === WebSocket.OPENcheck so heartbeat pings are not sent on closing/closed sockets during reconnectThis aligns
createHeartbeat()insrc/client.tswith the existing pattern insrc/services/realtime.ts.Test plan
INVALID_STATE_ERRORcrash and Realtime resumes normally