tsx icon indicating copy to clipboard operation
tsx copied to clipboard

SIGINT results in a forced exit every time when running `tsx watch` with npm

Open jabrks opened this issue 1 year ago • 8 comments

Acknowledgements

  • [X] I read the documentation and searched existing issues to avoid duplicates
  • [X] I am reporting a confirmed bug (not seek debugging help)
  • [X] I understand this is a collaborative project and relies on my contributions
  • [X] I read and understood the Contribution guide

Minimal reproduction URL

https://github.com/jabrks/tsx-reproduction

Problem & expected behavior (under 200 words)

Using npm to run tsx watch results in the following error each time the process is interrupted

[tsx] Previous process hasn't exited yet. Force killing...

The GitHub action in the reproduction linked above demonstrates this by artificially exiting the process after 3 seconds. npm's signal handling behaviour was changed in v10.3.0 as a result of https://github.com/npm/run-script/pull/188 which seems to be related

Bugs are expected to be fixed by those affected by it

  • [ ] I'm interested in working on this issue

Compensating engineering work financially will speed up resolution

  • [ ] I'm willing to offer financial support

jabrks avatar Jun 12 '24 15:06 jabrks

having same issue :(

JCMais avatar Oct 27 '24 22:10 JCMais

Same here :(

gcrozariol avatar Nov 01 '24 23:11 gcrozariol

I'm also seeing this with

pnpm tsx watch [...args]

mystery-house avatar Nov 19 '24 19:11 mystery-house

I see that when I use the command "tsx watch index.ts", this snippet:

process.on("SIGINT", () => { console.log("Received SIGINT signal"); process.exit(0); });

does not log the sentence "Received SIGINT signal" when I press ctrl+c

AssafFogelman avatar Feb 06 '25 12:02 AssafFogelman

Also having this issue when SIGINT is received my process starts graceful shutdown. but tsx does not let it exit properly and kills it.

safareli avatar Mar 03 '25 10:03 safareli

actually issue is not with tsx but pnpm if I run ./node_modules/.bin/tsx watch ./my-script exit works well. I experience the issue with pnpx tsx watch ...

safareli avatar Mar 03 '25 10:03 safareli

see issue on pnpm https://github.com/pnpm/pnpm/issues/7374 (which is still open)

safareli avatar Mar 03 '25 10:03 safareli

turbowatch has some motivations written, possibly related, and others https://github.com/gajus/turbowatch?#motivation as well as some watchers choices and drawbacks, in attempt to fix certain issues. If they are not yet, I suppose tsx should be aware of them.

dougg0k avatar May 28 '25 14:05 dougg0k