Open jiftoo opened 1 month ago
I have also experienced this issue. Since the release of Bun 1.1 I have been trying to migrate from npm to bun, however this issue that running scripts in package.json does not allow the script SIGINT handler to execute is preventing me from doing so
@jiftoo Any updates?
I use the following:
let currentProc: Subprocess | null = null
let serve = async () => {
if (currentProc) {
currentProc.kill()
await currentProc.exited
}
currentProc = Bun.spawn({
cmd: [
'bun',
'run',
// 'pylon-server', // DOES NOT WORK
'/Users/schettn/Documents/pylon/node_modules/.bin/pylon-server', // WORKS
'--port',
options.port
],
stdout: 'inherit',
onExit: () => {
console.log('Process exited')
}
})
}
await serve()
setInterval(async () => {
console.log('Rebuilding')
await serve()
console.log('Rebuilt')
}, 10000)
The problem is that when I want to spawn bun run pylon-server
the PID
is not from /Users/schettn/Documents/pylon/node_modules/.bin/pylon-server'. Instead the
PIDof
currentProc`.
Therefore I cannot call currentProc.kill()
and restart my server.
What version of Bun is running?
1.1.10+5102a9443
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What steps can reproduce the bug?
main.ts
package.json
What is the expected behavior?
The following printed to stdout on interrupt (Ctrl+C) when either of the following commands is ran:
bun main.ts
bun start
What do you see instead?
When running
bun main.ts
, the output is correct. When runningbun start
, the output is either empty or truncated.Additional information
Invoking SIGINT via
process.emit("SIGINT", "SIGINT");
works correctly in either case. Doesbun start
kill the script it's running shortly after it receives an interrupt signal?