Skip to content

stream/iter: pipeTo retries accepted PushWriter writes under block backpressureΒ #63296

@trivikr

Description

@trivikr

Version

26.1.0

Platform

macOS 26.5.0

Subsystem

stream

What steps will reproduce the bug?

import { pipeTo, push, text } from "node:stream/iter";

const enc = new TextEncoder();

async function repro(source) {
  const { writer, readable } = push({
    highWaterMark: 1,
    backpressure: "block",
  });

  const piping = pipeTo(source(), writer);

  // Let pipeTo() fill the PushWriter queue before the reader drains it.
  await new Promise(setImmediate);

  const output = await text(readable);
  await piping;
  return output;
}

async function* writevSource() {
  yield [enc.encode("ab")];
  yield [enc.encode("c"), enc.encode("d")];
}

async function* writeSource() {
  yield [enc.encode("a")];
  yield [enc.encode("b")];
}

console.log(await repro(writevSource)); // actual: abcdcd, expected: abcd
console.log(await repro(writeSource)); // actual: abbb, expected: ab

Run with

node --experimental-stream-iter repro.js

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

Always

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

abcd
ab

What do you see instead?

abcdcd
abbb

Additional information

No response

Metadata

Metadata

Assignees

Labels

streamIssues and PRs related to the stream subsystem.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions