bun
bun copied to clipboard
Bun shell exits process with exit code 0
What version of Bun is running?
1.1.0
What platform is your computer?
Darwin 23.0.0 arm64 arm
What steps can reproduce the bug?
run following code with dependencies
const runner = async (endpoint: string) => {
await $`npx get-graphql-schema ${endpoint} | grep -v "@connection" > ./src/schema.graphql`;
console.log('a')
try {
await $`pnpm relay`;
} catch (error) {
console.error('[getSchema] relay compilation failed', error);
process.exit(1);
}
};
What is the expected behavior?
graphql introspection should be done if endpoint is valid graphql endpoint, print 'a' to console output, then relay compile should run.
What do you see instead?
graphql introspection works fine, but the process exit right after it. not even 'a' printed out.
Additional information
the process's exit code is 0
can you provide an easier to reproduce code snippet? as-is, this code won't run
sorry for the incomplete information. I found the exact same graphql endpoint which generates the same status what I've got.
endpoint = https://graphql.anilist.co/graphql
- the command
(npx get-graphql-schema {endpoint} | grep -v "@connection" > ./src/schema.graphql
perfectly works on my native shell(zsh), with exit code 0. - the same command in bun shell, shows the same issue as the topic.
- the minimum reproduction command is
npx get-graphql-schema {endpoint} > ./meh.txt
. without writing to file works perfectly fine. but when I try to get output text from the command like$`npx get-grahpql-schema {endpoint}`.text()
, also shows the same behavior as described on the topic. -
const {stdout} = $`npx get-grahpql-schema {endpoint}`; Bun.write('./schema.graphql', stdout.toString())
worked without an issue, butconst {stdout} = $`npx get-grahpql-schema {private endpoint}.quiet()`; Bun.write('./schema.graphql', stdout.toString())
in order to suppress printed stdout from terminal, also doesn't work as said on the topic.
the issue also can be reproduced on 1.1.1.
I've encountered a variation of this with the .quiet()
modifier, where this code never prints 'DEBUG'
due to an immediate exit:
try {
await Bun.$`cd ${path} && bun link`.quiet();
console.log('DEBUG')
} catch (e) {
console.log('DEBUG')
}
Get the same bad behaviour if I use the --silent
flag as in Bun.$`cd ${path} && bun link --silent`
. Works fine if neither the .quiet()
modifier or --silent
flag are present. Switched back to using promisified exec
as it's more reliable.
I too am hitting this bug. This works fine:
const { stdout, stderr, exitCode } = await $`git ls-files ${dirPath}`.nothrow();
But if I add the .quiet()
the process exits:
dlog('getExistingGitFiles: dirPath:', dirPath);
const { stdout, stderr, exitCode } = await $`git ls-files ${dirPath}`.nothrow().quiet();
dlog({exitCode, stderr});
I see the first log message but not the second.