From 1a5cad40a2eedf1eb848157cb1944a8ca556d775 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Tue, 12 Aug 2025 13:01:16 +0000 Subject: [PATCH] chore: clean-up critical error handling --- src/index.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 813856f..944eb3e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,16 +17,6 @@ if (envIsProd()) { console.log = console.warn = console.error = console.info = console.debug = () => { /* disable in favor of logger */ }; } -// At your app’s entry point -process.on('uncaughtException', (err) => { - console.error('Uncaught exception caught:', err); - // Decide: exit gracefully or continue -}); - -process.on('unhandledRejection', (reason) => { - console.error('Unhandled rejection:', reason); -}); - const logger = winston.createLogger({ transports: [ new winston.transports.Console({ @@ -38,6 +28,14 @@ const logger = winston.createLogger({ ], }); +process.on('uncaughtException', (error) => { + logger.error('Uncaught exception caught:', error); +}); + +process.on('unhandledRejection', (reason) => { + logger.error('Unhandled rejection: ', reason); +}); + if (process.env['ALL_PROXY']) { const proxyUrl = new URL(process.env['ALL_PROXY']); if (proxyUrl.protocol === 'socks5:') {