From 8f67258b79f91a7ab4c3fd429730cccbac29acf0 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Fri, 26 Dec 2025 18:17:07 +0800 Subject: [PATCH 1/2] fix: Warn if a hook function forgets return when it is of pipe mode --- boot/boot.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/boot/boot.js b/boot/boot.js index ce713916d..48e2d7780 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -2735,7 +2735,12 @@ $tw.hooks.invokeHook = function(hookName /*, value,... */) { var args = Array.prototype.slice.call(arguments,1); if($tw.utils.hop($tw.hooks.names,hookName)) { for(var i = 0; i < $tw.hooks.names[hookName].length; i++) { + var previousValue = args[0]; args[0] = $tw.hooks.names[hookName][i].apply(null,args); + // Warn if a hook function forgets return when it is of pipe mode + if(args[0] === undefined && previousValue !== undefined) { + console.warn("Hook '" + hookName + "' handler at index " + i + " returned undefined. Expected the handler to return the value for the next hook in the chain. Handler function:", $tw.hooks.names[hookName][i].toString().substring(0, 200) + "..."); + } } } return args[0]; From da84d7b551a47872557876879142654da5b6b949 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Fri, 26 Dec 2025 22:20:18 +0800 Subject: [PATCH 2/2] Update boot.js --- boot/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/boot.js b/boot/boot.js index 48e2d7780..4dcedf4e0 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -2739,7 +2739,7 @@ $tw.hooks.invokeHook = function(hookName /*, value,... */) { args[0] = $tw.hooks.names[hookName][i].apply(null,args); // Warn if a hook function forgets return when it is of pipe mode if(args[0] === undefined && previousValue !== undefined) { - console.warn("Hook '" + hookName + "' handler at index " + i + " returned undefined. Expected the handler to return the value for the next hook in the chain. Handler function:", $tw.hooks.names[hookName][i].toString().substring(0, 200) + "..."); + console.warn("Hook '" + hookName + "' handler at index " + i + " returned undefined. Expected the handler to return the value for the next hook in the chain. Handler function:", $tw.hooks.names[hookName][i]); } } }