MCPcopy Index your code
hub / github.com/Ptechgithub/pp-worker / safeCloseWebSocket

Function safeCloseWebSocket

_worker.js:685–693  ·  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

683 * @param {import("@cloudflare/workers-types").WebSocket} socket The WebSocket connection to close.
684 */
685function safeCloseWebSocket(socket) {
686 try {
687 if (socket.readyState === WS_READY_STATE_OPEN || socket.readyState === WS_READY_STATE_CLOSING) {
688 socket.close();
689 }
690 } catch (error) {
691 console.error('safeCloseWebSocket error', error);
692 }
693}
694
695const byteToHex = [];
696

Callers 4

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

Calls

no outgoing calls

Tested by

no test coverage detected