Skip to content

stream: Readable.from with null #32845

@ronag

Description

@ronag

Reading through the Readable.from code is seems to me that the semantics of using Readable.from on a generator which yields null is not entirely clear.

Should we add a check for value == null and throw?

  async function next() {
    try {
      const { value, done } = await iterator.next();
      if (done) {
        readable.push(null);
      } else if (readable.push(await value)) { // Hm, push(null) and then next()?
        next();
      } else {
        reading = false;
      }
    } catch (err) {
      readable.destroy(err);
    }
  }

Might also want to be a bit more explicit in the docs about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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