oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.48k stars 2.78k forks source link

`process.stdout.read` does not exist #14968

Open CanadaHonk opened 3 weeks ago

CanadaHonk commented 3 weeks ago

What version of Bun is running?

1.1.32+fe8d0079e

What platform is your computer?

Linux 6.11.3-200.fc40.x86_64 x86_64 unknown

What steps can reproduce the bug?

bun --print "typeof process.stdout.read"

What is the expected behavior?

function

What do you see instead?

undefined

Additional information

No response

guest271314 commented 3 weeks ago

I'm curious how you are using process.stdout.read()?

guest271314 commented 3 weeks ago

@CanadaHonk What is the use case for process.stdout.read?

guest271314 commented 3 weeks ago

I didn't find a single example of process.stdout.read() being used in Node.js documenta, and no examples in the wild.

process.stdout.read() appears to be just a useless Node.js function.

I asked on Reddit. Nobody could articulate a use or use case for process.stdout.read().

This is the answer from Reddit that makes the most sense, to me.

What are the use cases for Node.js' process.stdout.read()?

process.stdout functions by automatically outputting what was written to it, without being read. It cannot be read. It's writable only.

It has the .read() method on it, because it inherits it from theEventEmitter class (which the Stream class extends), and is part of the whole stream API.

But it's vestigial. It doesn't actually work. It's just there as a consequence of inheritance, and nothing more. Nobody is using process.stdout.read() in code, because it's not a readable stream. You can't read from it.

That's your answer. You CANNOT read from stdout. The read() method is an artifact.

If anybody can contest the above conclusion that Node.js process.stdout.read() is a useless Node.js artifact, kindly share reproducible code here where process.stdout.read() is used. Thanks.