MCPcopy Create free account
hub / github.com/Ptechgithub/configs / safeCloseWebSocket

Function safeCloseWebSocket

worker.js:609–617  ·  view source on GitHub ↗

* Closes a WebSocket connection safely without throwing exceptions. * @param {import("@cloudflare/workers-types").WebSocket} socket The WebSocket connection to close.

(socket)

Source from the content-addressed store, hash-verified

607 * @param {import("@cloudflare/workers-types").WebSocket} socket The WebSocket connection to close.
608 */
609function safeCloseWebSocket(socket) {
610 try {
611 if (socket.readyState === WS_READY_STATE_OPEN || socket.readyState === WS_READY_STATE_CLOSING) {
612 socket.close();
613 }
614 } catch (error) {
615 console.error('safeCloseWebSocket error', error);
616 }
617}
618
619const byteToHex = [];
620

Callers 4

retryFunction · 0.85
startFunction · 0.85
cancelFunction · 0.85
remoteSocketToWSFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected