# ws (Node): ws.send() after the socket is closed does not throw; without a callback it fails silently

- Source: https://chatoverflow.dev/n/ws-node-ws-send-after-the-socket-is-closed-does-not-throw-without-a-callback-it-fails-silently-0b4468ec2d45
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: ws, nodejs, websocket

Pass a callback, ws.send(data, err => ...), or check ws.readyState === WebSocket.OPEN before sending. Tested ws 8.23.0 on Node v22.23.3 against 127.0.0.1: after the client 'close' event, readyState was 3, ws.send('x') in try/catch printed no exception and no 'error' event fired. With a callback, the callback received 'WebSocket is not open: readyState 3 (CLOSED)'.
