diff options
| author | dakkar <dakkar@thenautilus.net> | 2025-07-28 19:28:01 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2025-07-28 19:28:01 +0000 |
| commit | ce3531ed96da39a4e62cb3651df0b8aee49b912f (patch) | |
| tree | 4def24de3c615351ba6ab86390029b393a81fa2f /packages/backend/src/boot | |
| parent | merge: Fix Postgres / TypeORM errors *FOR STABLE* (!1192) (diff) | |
| parent | fix DI error in HttpRequestService.ts (diff) | |
| download | sharkey-ce3531ed96da39a4e62cb3651df0b8aee49b912f.tar.gz sharkey-ce3531ed96da39a4e62cb3651df0b8aee49b912f.tar.bz2 sharkey-ce3531ed96da39a4e62cb3651df0b8aee49b912f.zip | |
merge: Improve URL validation *FOR STABLE* (!1191)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1191
Approved-by: Hazelnoot <acomputerdog@gmail.com>
Diffstat (limited to 'packages/backend/src/boot')
| -rw-r--r-- | packages/backend/src/boot/entry.ts | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/packages/backend/src/boot/entry.ts b/packages/backend/src/boot/entry.ts index afb48e526c..bbe6a57383 100644 --- a/packages/backend/src/boot/entry.ts +++ b/packages/backend/src/boot/entry.ts @@ -55,44 +55,42 @@ async function main() { // Display detail of unhandled promise rejection if (!envOption.quiet) { process.on('unhandledRejection', e => { - try { - logger.error('Unhandled rejection:', inspect(e)); - } catch { - console.error('Unhandled rejection:', inspect(e)); - } + logger.error('Unhandled rejection:', inspect(e)); }); } - // Display detail of uncaught exception - process.on('uncaughtExceptionMonitor', ((err, origin) => { - try { - logger.error(`Uncaught exception (${origin}):`, err); - } catch { - console.error(`Uncaught exception (${origin}):`, err); + process.on('uncaughtException', (err) => { + // Workaround for https://github.com/node-fetch/node-fetch/issues/954 + if (String(err).match(/^TypeError: .+ is an? url with embedded credentials.$/)) { + logger.debug('Suppressed node-fetch issue#954, but the current job may fail.'); + return; + } + + // Workaround for https://github.com/node-fetch/node-fetch/issues/1845 + if (String(err) === 'TypeError: Cannot read properties of undefined (reading \'body\')') { + logger.debug('Suppressed node-fetch issue#1845, but the current job may fail.'); + return; } - })); + + // Throw all other errors to avoid inconsistent state. + // (per NodeJS docs, it's unsafe to suppress arbitrary errors in an uncaughtException handler.) + throw err; + }); + + // Display detail of uncaught exception + process.on('uncaughtExceptionMonitor', (err, origin) => { + logger.error(`Uncaught exception (${origin}):`, err); + }); // Dying away... process.on('disconnect', () => { - try { - logger.warn('IPC channel disconnected! The process may soon die.'); - } catch { - console.warn('IPC channel disconnected! The process may soon die.'); - } + logger.warn('IPC channel disconnected! The process may soon die.'); }); process.on('beforeExit', code => { - try { - logger.warn(`Event loop died! Process will exit with code ${code}.`); - } catch { - console.warn(`Event loop died! Process will exit with code ${code}.`); - } + logger.warn(`Event loop died! Process will exit with code ${code}.`); }); process.on('exit', code => { - try { - logger.info(`The process is going to exit with code ${code}`); - } catch { - console.info(`The process is going to exit with code ${code}`); - } + logger.info(`The process is going to exit with code ${code}`); }); //#endregion |