Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eavidy opened this issue Dec 16, 2024 · 0 comments
Open

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

eavidy opened this issue Dec 16, 2024 · 0 comments

Comments

@eavidy
Copy link

eavidy commented Dec 16, 2024

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

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

No branches or pull requests

2 participants