summaryrefslogtreecommitdiff
path: root/packages/backend/src/boot/entry.ts
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-17 20:31:00 -0400
committerdakkar <dakkar@thenautilus.net>2025-07-27 17:57:30 +0100
commit283facdd31e1dc43fb457a97cdb8677d38e08bcf (patch)
treef0eafff42164a0243b1b630c8493245a4c0676ce /packages/backend/src/boot/entry.ts
parentfix URL errors from incorrect validation in validateActor (diff)
downloadsharkey-283facdd31e1dc43fb457a97cdb8677d38e08bcf.tar.gz
sharkey-283facdd31e1dc43fb457a97cdb8677d38e08bcf.tar.bz2
sharkey-283facdd31e1dc43fb457a97cdb8677d38e08bcf.zip
add workarounds for node-fetch crashes
Diffstat (limited to 'packages/backend/src/boot/entry.ts')
-rw-r--r--packages/backend/src/boot/entry.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/packages/backend/src/boot/entry.ts b/packages/backend/src/boot/entry.ts
index afb48e526c..af4a813833 100644
--- a/packages/backend/src/boot/entry.ts
+++ b/packages/backend/src/boot/entry.ts
@@ -63,14 +63,32 @@ async function main() {
});
}
+ 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.$/)) {
+ console.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\')') {
+ console.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) => {
+ process.on('uncaughtExceptionMonitor', (err, origin) => {
try {
logger.error(`Uncaught exception (${origin}):`, err);
} catch {
console.error(`Uncaught exception (${origin}):`, err);
}
- }));
+ });
// Dying away...
process.on('disconnect', () => {