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 · 0 comments
Open

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

dhbaird opened this issue Jun 17, 2024 · 0 comments
Labels
bug Something isn't working needs triage

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.

@dhbaird dhbaird added bug Something isn't working needs triage labels Jun 17, 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 needs triage
Projects
None yet
Development

No branches or pull requests

1 participant