Two issues in the hooks pipeline (agent-reported; [needs repro] but grounded in the code).
1. try/catch can invoke the callback twice
packages/dredd/lib/TransactionRunner.js:361-405 (runHookWithData). The try/catch wraps the entire callback chain, so an error thrown after this.runHook(...) (e.g. inside runHookCallback()) is caught and runHookCallback() is called again. The code itself comments that this is "very problematic."
Fix: wrap only the this.runHook() call, or guard with a once-flag so the callback fires exactly once.
2. Hook-load errors swallowed
packages/dredd/lib/addHooks.js:23-34 (loadHookFile). An invalid hook file only emits logger.warn and execution continues without the hooks the user expected — unlike the fail-fast hookHandlerError pattern used elsewhere.
Decision needed: propagate the error (fail fast) vs. keep warn-and-continue. If kept, document it as intentional.
Tasks
Two issues in the hooks pipeline (agent-reported; [needs repro] but grounded in the code).
1. try/catch can invoke the callback twice
packages/dredd/lib/TransactionRunner.js:361-405(runHookWithData). Thetry/catchwraps the entire callback chain, so an error thrown afterthis.runHook(...)(e.g. insiderunHookCallback()) is caught andrunHookCallback()is called again. The code itself comments that this is "very problematic."Fix: wrap only the
this.runHook()call, or guard with a once-flag so the callback fires exactly once.2. Hook-load errors swallowed
packages/dredd/lib/addHooks.js:23-34(loadHookFile). An invalid hook file only emitslogger.warnand execution continues without the hooks the user expected — unlike the fail-fasthookHandlerErrorpattern used elsewhere.Decision needed: propagate the error (fail fast) vs. keep warn-and-continue. If kept, document it as intentional.
Tasks
runHookWithDataand/or add a once-guard on the callback.