sincecutoff.com
← all changes

k6 WebSocket exposes ready-state constants

Introduced 2026-09-21 · score 0.91

HOW TO USE IT

When reviewing WebSocket message handling, check the socket state before sending. Send only when `socket.readyState === WebSocket.OPEN`; `OPEN` means the connection is ready to communicate.

if (socket.readyState === WebSocket.OPEN) { socket.send('hello'); }

WHY THIS HELPS

When reviewing WebSocket message handling, check a socket's state before sending a message.

REQUIREMENTS AND LIMITATIONS

  • Version: v2.3.0
  • socket.readyState (required): Current connection state; compare it with a ready-state constant.
  • WebSocket.OPEN (required): Constant with value `1`; connection is open and ready to communicate. Constants are read-only and also available on each instance.
  • socket.send(data) (required): Sends data through the WebSocket.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card