sincecutoff.com
← all changes

k6 experimental streams WritableStream and WritableStreamDefaultWriter

Introduced 2026-08-10 · score 0.93

HOW TO USE IT

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.

import { WritableStream } from 'k6/experimental/streams'; export default async function () { const stream = new WritableStream({ write(chunk) { console.log(`wrote ${chunk}`); }, }); const writer = stream.getWriter(); await writer.write('hello'); await writer.close(); }

WHY THIS HELPS

When implementing a writable stream in a k6 script, use the experimental streams module.

REQUIREMENTS AND LIMITATIONS

  • 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.

FIRST-PARTY EVIDENCE

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

Report a problem with this card