FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Refine WebSocket connection management logic by bretamerman · Pull Request #145 · stoatchat/javascript-client-sdk · GitHub

fix: Refine WebSocket connection management logic - #145

Open
bretamerman wants to merge 1 commit into
stoatchat:mainfrom
bretamerman:websockets-connection-timeouts
Open

fix: Refine WebSocket connection management logic#145
bretamerman wants to merge 1 commit into
stoatchat:mainfrom
bretamerman:websockets-connection-timeouts

Conversation

Copy link
Copy Markdown

adds guards to the heartbeat interval to prevent a send with an invalid socket updates connection timeout to use the connection timeout option uses clearTimeout for setTimeout and clearInterval for setInterval

Copy link
Copy Markdown
Author

Had a bot that was running the other day randomly die on me. Stack trace shows it failed on this line, this.send({ type: "Ping", data: +new Date() });.

2026-03-18 11:35:28.317 [error]: Client error occurred: Received network error or non-101 status code.
2026-03-18 11:35:29.775 [error]: Uncaught Exception: Sent before connected. {
  "stack": "InvalidStateError: Sent before connected.\n    at new DOMException (node:internal/per_context/domexception:53:5)\n    at WebSocket.send (node:internal/deps/undici/undici:12680:17)\n    at EventClient.send (file:///Users/.../node_modules/revolt.js/lib/events/EventClient.js:123:22)\n    at Timeout._onTimeout (file:///Users/.../node_modules/revolt.js/lib/events/EventClient.js:75:22)\n    at listOnTimeout (node:internal/timers:614:17)\n    at processTimers (node:internal/timers:549:7)"
}

adds guards to the heartbeat interval to prevent a send with an invalid socket
updates connection timeout to use the connection timeout option
uses clearTimeout for setTimeout and clearInterval for setInterval

Signed-off-by: Bret Amerman <bret.amerman@icloud.com>
bretamerman force-pushed the websockets-connection-timeouts branch from 08d28d9 to 2d5f1a4 Compare March 20, 2026 01:54
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL