Skip to content

Improper handling of graceful exits (same as #95) #708

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

Closed
4 of 6 tasks
greguz opened this issue Mar 14, 2025 · 7 comments
Closed
4 of 6 tasks

Improper handling of graceful exits (same as #95) #708

greguz opened this issue Mar 14, 2025 · 7 comments
Labels
bug Something isn't working pending triage

Comments

@greguz
Copy link

greguz commented Mar 14, 2025

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://github.com/greguz/tsx-issue

Problem & expected behavior (under 200 words)

My env:

  • Node.js v22.13.0
  • macOS 15.3.2 (24D81) (Apple M2 Pro)
  • tsx v4.19.3

Using the same code from #95 I can constantly trigger a double SIGINT with tsx (clean Node.js works).

console.log('starting up')

process.on('SIGINT', () => {
  console.log('shutting down')

  // simulate cleanup
  setTimeout(() => {
    console.log('cleanly exiting')
    process.exit(0)
  }, 5000)
})

// run forever
setInterval(() => {}, 1 << 30)
╭─greguz@prunix ~/Development/bug ‹master●› 
╰─$ npx tsx z.ts      
starting up
^Cshutting down
shutting down
cleanly exiting
╭─greguz@prunix ~/Development/bug ‹master●› 
╰─$ node z.js   
starting up
^Cshutting down
cleanly exiting

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support
@greguz greguz added bug Something isn't working pending triage labels Mar 14, 2025
@privatenumber
Copy link
Owner

Does this still happen if you run tsx directly, without npx?

@greguz
Copy link
Author

greguz commented Mar 14, 2025

That was unexpected! Is this behavior supposed to happen?

╭─greguz@prunix ~/Development/greguz/tsx-issue ‹master●› 
╰─$ ./node_modules/.bin/tsx z.ts 
starting up
^Cshutting down
cleanly exiting
╭─greguz@prunix ~/Development/greguz/tsx-issue ‹master●› 
╰─$ npx tsx z.ts
starting up
^Cshutting down
shutting down
cleanly exiting

@privatenumber
Copy link
Owner

I'm not sure 🤷‍♂️

You can report it to npx as that's the layer that's not handling your signal.

@privatenumber
Copy link
Owner

FYI I dont think this has anything to do with tsx.

You can likely reproduce with npx node z.js

@greguz
Copy link
Author

greguz commented Mar 14, 2025

Thank you for the fast support. I opened an issue to the npm project. I let you known how comes in the future 🙃

PS: this was a nasty bug for me, because the double SIGINT paired with close-with-grace kills the process instantly (and my poor AMQP connection is not happy about it).

@privatenumber
Copy link
Owner

privatenumber commented Mar 14, 2025

Yeah, I saw and I was responding to that indirectly.

Typically, issues require minimal reproductions, and your reproduction in npm/cli#8164 is technically not minimal because it can be reproduced without tsx.

It saves the maintainer time to keep the report slim and makes it obvious where the problem is.

@greguz
Copy link
Author

greguz commented Mar 14, 2025

You are absolutely right. I'll update the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

2 participants