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

stdio[3 + n] not working with child_process #11044

Open
Clemens-E opened this issue May 13, 2024 · 0 comments
Open

stdio[3 + n] not working with child_process #11044

Clemens-E opened this issue May 13, 2024 · 0 comments
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@Clemens-E
Copy link

Clemens-E commented May 13, 2024

What version of Bun is running?

1.1.8-canary.1+88468a2c2

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

It's possible to add extra stdio streams when spawning a child, bun provides those streams, but no message is received.
Nodejs receives them without issues

To reproduce:
child.js

import { createWriteStream } from 'fs';

const stdio3 = createWriteStream(null, { fd: 3 });
console.log('stdout: createWriteStream fd: 3')
stdio3.write('hi from bun! using fd 3')

index.js

import { spawn } from 'child_process';

const child = spawn('bun', ['src/child.js'], {
    stdio: ['inherit', 'inherit', 'inherit', 'pipe']
});

console.log(`${child.stdio.length} available file descriptors`)

child.stdio[3].on('data', d => console.log(`fd 3: ${d.toString()}`))

What is the expected behavior?

expected nodejs behavior:

$ node src/index.js 
4 available file descriptors
stdout: createWriteStream fd: 3
fd 3: hi from bun! using fd 3

What do you see instead?

$ bun src/index.js
4 available file descriptors
stdout: createWriteStream fd: 3

Additional information

Using Bun.spawn, we see that
bunSpawn.stdio (which is not documented, at least not in the types)
provides an integer at the position 4: [ null, null, null, 172 ]
I don't know what to do with this value, as passing it to createReadStream(null, {fd:bunSpawn.stdio[3]}) yields no data and instantly closes

This seems related to #6240

@Clemens-E Clemens-E added the bug Something isn't working label May 13, 2024
@Electroid Electroid added the node.js Compatibility with Node.js APIs label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

2 participants