Skip to content

Node.js based forum software built for the modern web

fix: don't crash if there are exceptions in action hooks

Barış Soner Uşaklı30068245d3a8
diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js
index 8a5d1a885d..553e90db45 100644
--- a/src/plugins/hooks.js
+++ b/src/plugins/hooks.js
@@ -275,8 +275,12 @@ async function fireActionHook(hook, hookList, params) {
winston.warn(`[plugins] Expected method for hook '${hook}' in plugin '${hookObj.id}' not found, skipping.`);
}
} else {
- // eslint-disable-next-line
- await hookObj.method(params);
+ try {
+ // eslint-disable-next-line
+ await hookObj.method(params);
+ } catch (err) {
+ winston.error(`[plugins] Error in hook ${hookObj.id}@${hookObj.hook} \n${err.stack}`);
+ }
}
}
}