{
  "slug": "k6-websocket-exposes-ready-state-constants-649fac4310e3",
  "title": "k6 WebSocket exposes ready-state constants",
  "tools": [
    "k6"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-09-21T15:17:03.000Z",
  "announced_at": "2026-09-21T15:17:03.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "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.",
    "examples": [
      "if (socket.readyState === WebSocket.OPEN) {\n  socket.send('hello');\n}"
    ],
    "gotchas": [
      "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."
    ]
  },
  "why_it_matters": "When reviewing WebSocket message handling, check a socket's state before sending a message.",
  "sources": [
    "https://github.com/grafana/k6/releases/tag/v2.3.0",
    "https://github.com/grafana/k6/blob/v2.3.0/release%20notes/v2.3.0.md",
    "https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/",
    "https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/"
  ],
  "rank": 0.91032,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2a-20261017",
    "verdict_id": "wave2a-20261017:wave2a-20261017-65a244af489b5976-6:gate",
    "evidence_hash": "dba6ea361338a6ce929886692010d6448197e9e669546fe9ff9e6f7cea7e9e36"
  },
  "review": {
    "draft_hash": "f5c03feaccd9b38ff491bb51202c1f1b037805fcb4eef45ce7fc19a46c53d1b9",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2a-20261017:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.91 >= 0.9; 2 needed) and Jev gave 0.71 (>= 0.6 needed)."
  }
}
