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

SIGINT has no effect if tsx is running an infinite loop #394

Closed
4 of 5 tasks
sadkebab opened this issue Nov 17, 2023 · 2 comments · Fixed by #395
Closed
4 of 5 tasks

SIGINT has no effect if tsx is running an infinite loop #394

sadkebab opened this issue Nov 17, 2023 · 2 comments · Fixed by #395
Labels

Comments

@sadkebab
Copy link
Contributor

sadkebab commented Nov 17, 2023

Precheck

  • I searched existing issues before opening this one to avoid duplicates
  • I'm able to reproduce this issue and prove it with a minimal reproduction
  • I understand this is not a place to ask for free debugging support

Problem

You have a file called file.ts with an infinite loop in it like while(true){}.
By running tsx file.ts you won't be able to stop the execution of tsx by sending a SIGINT (for example with CTRL+C) and the process will run indefinitely until it receives another signal like a SIGQUIT or a SIGSTOP.

Expected behavior

tsx should stop the execution after the SIGINT.

Minimal reproduction URL

https://stackblitz.com/edit/node-fc7ukf?file=index.ts

Version

v4.1.3

Node.js version

v20.7.0

Package manager

pnpm

Operating system

macOS

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@sadkebab
Copy link
Contributor Author

sadkebab commented Nov 17, 2023

The main issue that this behaviour created to me was that, by defining a script in a package.json like
"scripts": { "test": "tsx file.ts" } where file.ts would run an infinite loop, after executing it with pnpm test if I sent a couple of SIGINT by keyboard shortcut the script would quit... but the child process spawned by tsx was still running in the background, eating 100% cpu and draining the battery of my laptop.

@privatenumber
Copy link
Owner

🎉 This issue has been resolved in v4.4.0

If you appreciate this project, please consider supporting this project by sponsoring ❤️ 🙏

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants