fix: occasional 100% cpu on quitting
Massimo Melina committed
Apr 21, 2025 at 17:17 UTC
50aa7362dc4588bc78da53d70c023c6b67436547
1 file changed
+2
-1
src/index.ts
+2
-1
@@ -65,7 +65,8 @@ function errorHandler(err:Error & { code:string, path:string }) {
65
66
process.on('uncaughtException', (err: any) => {
67
if (err.syscall !== 'watch' && err.code !== 'ECONNRESET')
68
- console.error("uncaught:", err)
68
+ try { console.error("uncaught:", err) }
69
+ catch {} // in case we are writing to a closed terminal, we may throw with "write eio at afterwritedispatched", causing an infinite loop
70
})
71
// this warning is scaring users, and has been removed in node 20.12.0 https://github.com/nodejs/node/pull/51204
72
const original = process.emitWarning