Skip to content

Node.js based forum software built for the modern web

fix: crash on firing action hook that had no listeners registered

Julian Lamb0f5d5a5941c
diff --git a/public/src/modules/hooks.js b/public/src/modules/hooks.js
index 38ac1f5dcf..1a5b7cdf32 100644
--- a/public/src/modules/hooks.js
+++ b/public/src/modules/hooks.js
@@ -36,6 +36,10 @@ define('hooks', [], () => {
};
const _fireActionHook = (hookName, data) => {
+ if (!Hooks.hasListeners(hookName)) {
+ return;
+ }
+
Hooks.loaded[hookName].forEach(listener => listener(data));
// Backwards compatibility (remove this when we eventually remove jQuery from NodeBB core)