()
| 74 | const encoder = binaryMode ? new TextEncoder() : null; |
| 75 | |
| 76 | function createSocket(): WebSocket { |
| 77 | try { |
| 78 | // pylsp's websocket endpoint does not require subprotocol negotiation. |
| 79 | // Avoid passing protocols to keep the handshake simple. |
| 80 | const ws = new WebSocket(wsUrl); |
| 81 | if (binaryMode) { |
| 82 | ws.binaryType = "arraybuffer"; |
| 83 | } |
| 84 | return ws; |
| 85 | } catch (error) { |
| 86 | const message = error instanceof Error ? error.message : String(error); |
| 87 | throw new Error( |
| 88 | `Failed to construct WebSocket for ${server.id} (${wsUrl}): ${message}`, |
| 89 | ); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function handleMessage(event: MessageEvent): void { |
| 94 | let data: string; |
no test coverage detected