Skip to content

stream/iter: stateful stream transforms reject null output instead of emitting empty Uint8Array #64461

Description

@trivikr

Version

main

Platform

macOS 26.5.2

Subsystem

stream

What steps will reproduce the bug?

import { bytes, from, pull } from 'node:stream/iter';

const transform = {
  async *transform() {
    yield null;
  },
};

try {
  console.log(await bytes(pull(from('x'), transform)));
} catch (error) {
  console.log(error.code, error.message);
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Uint8Array(0) []

As per §9.3 Transforms

Transform return values are flexible. A transform may return: null (no output)
To normalize transform output given value: if value is null, return null.

null means no output, so the consumer completes with Uint8Array(0) []

What do you see instead?

ERR_INVALID_ARG_TYPE The "value" argument must be of type string or an instance of Uint8Array, ArrayBuffer, ArrayBufferView, Iterable, or AsyncIterable. Received null

A stateful transform yielding null throws ERR_INVALID_ARG_TYPE

Additional information

No response

Metadata

Metadata

Assignees

Labels

streamIssues and PRs related to the stream subsystem.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions