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

child_process.spawnSync() failure when readline module is also used #11918

Open
dhbaird opened this issue Jun 17, 2024 · 2 comments
Open

child_process.spawnSync() failure when readline module is also used #11918

dhbaird opened this issue Jun 17, 2024 · 2 comments
Labels
bug Something isn't working confirmed bug We can reproduce this issue node:child_process node:readline

Comments

@dhbaird
Copy link

dhbaird commented Jun 17, 2024

What version of Bun is running?

1.1.13

What platform is your computer?

Linux

What steps can reproduce the bug?

echo | bun fail.mjs

of the following:

// fail.mjs
import readline from "node:readline";
import child_process from "node:child_process";
import { stdin } from 'node:process';

const reader = readline.createInterface({ input: stdin });
reader.question("", () => {
    const { stdout } = child_process.spawnSync("bash", ["-c", "echo hello"], {
        input: new Uint8Array(0),  // works if Uint8Array(1)
        stdio: ["pipe", "pipe", "inherit"]
    });
    console.log(stdout);  // expect: Buffer(6) [ 104, 101, 108, 108, 111, 10 ]
});

What is the expected behavior?

Buffer(6) [ 104, 101, 108, 108, 111, 10 ]

What do you see instead?

bash: line 0: echo: write error: Bad file descriptor
Buffer(0) [ ]

Additional information

Works if input of spawnSync is Uint8Array(1).
Works if input of spawnSync is "" (empty string).
Works if reader.question() is removed.
Works with node.js.

@nektro
Copy link
Member

nektro commented Sep 13, 2024

does this still reproduce for you? I'm not seeing this on Bun 1.1.27 (you may need to run bun upgrade)

@RiskyMH RiskyMH added the confirmed bug We can reproduce this issue label Jan 7, 2025
@RiskyMH
Copy link
Member

RiskyMH commented Jan 7, 2025

I can reproduce on Bun 1.1.43 (Linux).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue node:child_process node:readline
Projects
None yet
Development

No branches or pull requests

3 participants