{
  "slug": "k6-experimental-streams-writablestream-and-writablestreamdefaultwriter-ab8ff3865bc1",
  "title": "k6 experimental streams WritableStream and WritableStreamDefaultWriter",
  "tools": [
    "k6"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-08-10T14:01:35.000Z",
  "announced_at": "2026-08-10T14:01:35.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When implementing a writable stream in k6 v2.2.0, import `WritableStream` from `k6/experimental/streams`. Create it with a `write` handler, then call `getWriter()`, `write()`, and `close()` as shown.",
    "examples": [
      "import { WritableStream } from 'k6/experimental/streams';\n\nexport default async function () {\n  const stream = new WritableStream({\n    write(chunk) {\n      console.log(`wrote ${chunk}`);\n    },\n  });\n\n  const writer = stream.getWriter();\n  await writer.write('hello');\n  await writer.close();\n}"
    ],
    "gotchas": [
      "Version: v2.2.0",
      "Availability: Experimental streams module.",
      "write(chunk): The example’s underlying sink handler receives a chunk and logs it. The release note does not document whether the handler is required.",
      "writer.write('hello') (required): Writes the `hello` chunk in the documented example.",
      "writer.close() (required): Closes the writer in the documented example.",
      "Prerequisite: Use k6 v2.2.0 or later for the release-note implementation described here; the module is experimental.",
      "Prerequisite: Install k6 to write and execute k6 scripts.",
      "Implements WritableStream and WritableStreamDefaultWriter following the WHATWG Streams specification."
    ]
  },
  "why_it_matters": "When implementing a writable stream in a k6 script, use the experimental streams module.",
  "sources": [
    "https://github.com/grafana/k6/releases/tag/v2.2.0",
    "https://grafana.com/docs/k6/latest/get-started/write-your-first-test/"
  ],
  "rank": 0.93026,
  "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-c50b860ccf230af2-3:gate",
    "evidence_hash": "5029169f942862caa4fcc22c402f7f04b7ddcfb75af24cf8ee5e89a592ecd7bf"
  },
  "review": {
    "draft_hash": "c0a05c640d186e2f6e4ccc9888d807baa985f9fcfbbee7deb8f4457f0be46973",
    "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.93 >= 0.9; 2 needed) and Jev gave 0.62 (>= 0.6 needed)."
  }
}
