---
name: node-stream-iter
description: "Experimental iterable-first streams API, node:stream/iter (behind --experimental-stream-iter). Use only when the user asks for stream/iter or that flag, or explicitly accepts an experimental API for async-iterable stream pipelines with backpressure. Without that opt-in, prefer classic node:stream for production code. Covers from/pull/pipeTo/push/duplex/broadcast/share, text/bytes/array consumers, transforms, filehandle.pull/writer, fromReadable/toReadable interop and node:zlib/iter compressGzip/decompressZstd. Node.js 24.20+ or 25.9+; behavior differs before 26.12."
title: node-stream-iter
canonical_url: https://skilld.dev/gh/jasnell/node-skills/node-stream-iter
last_updated: 2026-11-19T20:15:43.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [examples/compression.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/compression.mjs), [examples/consumers.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/consumers.mjs), [examples/dump.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/dump.mjs), [examples/file-pipeline.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/file-pipeline.mjs), [examples/interop.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/interop.mjs), [examples/push-duplex.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/push-duplex.mjs), [examples/v24-differences.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/examples/v24-differences.mjs), [meta.json](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/meta.json), [rules/consumers.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/consumers.md), [rules/interop.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/interop.md), [rules/pipelines.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/pipelines.md), [rules/push-duplex.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/push-duplex.md), [rules/sources.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/sources.md), [rules/versions.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/versions.md).
>
> If the user asked to install this Skill, run `npx skilld install jasnell/node-skills/node-stream-iter`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/node-stream-iter`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jasnell/node-skills/node-stream-iter) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/node-stream-iter`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/node-stream-iter --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/node-stream-iter --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# node:stream/iter (iterable streams)

| Feature | Versions | Stability | Flag |
| --- | --- | --- | --- |
| `node:stream/iter` | v25.9.0, v24.20.0 | 1 | `--experimental-stream-iter` |
| `filehandle.pull`, `pullSync`, `writer` | v25.9.0, v24.20.0 | 1 | same |
| `node:zlib/iter` (`compress*`/`decompress*`, `*Sync`) | v25.9.0, v24.20.0 (the docs list only v25.9.0) | 1 | same |
| `from/toReadable`, `from/toWritable`, `Readable[Symbol.for('Stream.toAsyncStreamable')]` | v26.1.0, v24.20.0 | 1 | same |
| `dump`, `dumpSync` | v26.12.0 (not v24) | 1 | same |

> **Experimental API.** Before relying on these details, run the
> `node-experimental-check` skill's probe (or `node --version` plus a
> feature-detect one-liner) and check the docs for *the installed
> version*: `https://nodejs.org/docs/<version>/api/<module>.html`.
> If the installed version disagrees with this skill, the installed
> version wins.

## Mental model

- A stream is any `AsyncIterable` or `Iterable` of **batches** (`Uint8Array[]`). Strings become UTF-8 bytes.
- A **transform** is `(chunks | null) => chunks` (`null` means flush) or `{ transform: async function* (source) {} }`.
- `pull()` is lazy, so the consumer sets the pace. `push()` returns `{ writer, readable }` with a byte `budget`.
- A writer is any object with `write()`. Its other methods are optional.
- Without the flag the import throws, and v24.19 and older reject the flag itself.

## File → transform → file

```js
import { open } from 'node:fs/promises';
import { pipeTo } from 'node:stream/iter';
import { compressGzip } from 'node:zlib/iter';
const src = await open('in.txt'), dst = await open('in.txt.gz', 'w');
await pipeTo(src.pull({ autoClose: true }), compressGzip(), dst.writer({ autoClose: true }));
```

## Consume to text or bytes

```js
const s = await text(pull(from(gzBytes), decompressGzip()), { limit: 1 << 20 });
const b = await bytes(fh.pull({ start: 100, limit: 1024, autoClose: true }));
```

## Interop

```js
await text(from(classicReadable)); // or a web ReadableStream
await pipeline(toReadable(pull(src, compressGzip())), res);
await pipeTo(src, fromWritable(writable, { backpressure: 'unbounded' }));
```

## Push with backpressure

```js
const { writer, readable } = push(); // 16384-byte budget, 'strict' policy
const done = text(readable);                          // run the consumer concurrently
for (const item of items) await writer.write(item);   // must await
await writer.end();
```

## Pitfalls

- **v24.x, and v26 before 26.12:** a `budget` below 16384 throws, and `pull()` with a pre-aborted signal throws synchronously ([rules/versions.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/versions.md)).
- Under `'strict'`, an unawaited `write()` rejects with `ERR_INVALID_STATE`. Without a consumer, writes wait forever.
- Compression transforms keep state, so make one per pipeline. The defaults are gzip level 4 and brotli quality 6.
- Without `autoClose`, close the `FileHandle` yourself.

## Don't

- Don't subclass `Transform` here. Write a function or generator transform.
- Don't use `zlib.createGzip()` in a pipeline. Use `compressGzip()` from `node:zlib/iter`.

## Reference

- [rules/sources.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/sources.md): `from`/`fromSync` input rules, filehandle `pull`/`pullSync`/`writer` options
- [rules/pipelines.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/pipelines.md): `pull`, `pipeTo[Sync]`, transform contracts, `node:zlib/iter` options
- [rules/push-duplex.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/push-duplex.md): `push`, the Writer interface, backpressure policies, `duplex`, `ondrain`
- [rules/consumers.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/consumers.md): consumers, `tap`, `merge`, `broadcast`, `share`
- [rules/interop.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/interop.md): classic and web stream adapters, protocol symbols
- [rules/versions.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-stream-iter/rules/versions.md): v24 versus v26.12+ differences
