A handler for a WebSocket connection error event. For multiple, simultaneous event handlers, use WebSocket.addEventListener().
Example
A k6 script that initiates a WebSocket connection and sets up a handler for the error event.
example-websocket-onerror.js
The preceding example uses a WebSocket echo server, which you can run with the following command: