Skip to content

The desiredSize of Writable.toWeb() is incorrect #56269

Description

@eavidy

Version

v22.12.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

import { Writable } from "node:stream";

const nodeWriteable = new Writable({
  write(chunk, encoding, callback) {
    // pending
  },
  highWaterMark: 5,
  objectMode: false,
});
const webWritable = Writable.toWeb(nodeWriteable);
const writer = webWritable.getWriter();
writer.write(new Uint8Array(3));
console.log(nodeWriteable.writableLength, writer.desiredSize); // expect 3,2  actual 0,4

let promise = writer.write(new Uint8Array(3));

console.log(nodeWriteable.writableLength, writer.desiredSize); // expect  6, -1, actual  0,3

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

always

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

I think writer.desiredSize should be equal to highWaterMark - odeWriteable.writableLength
Otherwise, after the Writable.toWeb() conversion, the buffer queue for the writable stream is expanded

What do you see instead?

none

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.web streamsIssues and PRs related to the Web Streams API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions