privatenumber / tsx

⚡️ TypeScript Execute | The easiest way to run TypeScript in Node.js
https://tsx.is
MIT License
9.43k stars 144 forks source link

No event fired in watch mode #494

Closed clonecorp closed 6 months ago

clonecorp commented 6 months ago

Acknowledgements

Minimal reproduction URL

No reproduction

Version

v0.0.0

Node.js version

v20

Package manager

pnpm

Operating system

Windows

Problem & Expected behavior

What happened? No process.on('SIGINT') nor any other event is fired before the tsx watch mode recompiles the code

What did you expect instead? I expect to be able to get an event on watch mode (when saving a file) to close dependencies and disconnect from my database with prisma.$disconnect() to avoid getting this error: "[FATAL: sorry, too many clients already]". Since the watch mode doesn't fire any event, connections keep piling up and there's no disconnection made. Also, since it recompiles everything, it doesn't "save" the connection made and just keeps it idle.

Let me know if there is a possibility to get at least an event on the process to kill the connections that need to be killed.

Thanks.

Contributions