From 744321736a30ddcbff7b498f0e40787d9ba9b7ee Mon Sep 17 00:00:00 2001 From: Sven Sterbling Date: Fri, 25 Oct 2024 11:59:44 +0200 Subject: [PATCH] fix: disabled breaker emits fire events To revert to previous behaviour up to v8.1.4. https://github.com/nodeshift/opossum/issues/894 --- lib/circuit.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/circuit.js b/lib/circuit.js index 2a541ded..c730634e 100644 --- a/lib/circuit.js +++ b/lib/circuit.js @@ -619,6 +619,13 @@ class CircuitBreaker extends EventEmitter { const args = rest.slice(); + /** + * Emitted when the circuit breaker action is executed + * @event CircuitBreaker#fire + * @type {any} the arguments passed to the fired function + */ + this.emit('fire', args); + // Protection, caches and coalesce disabled. if (!this[ENABLED]) { const result = this.action.apply(context, args); @@ -630,13 +637,6 @@ class CircuitBreaker extends EventEmitter { // Need to create variable here to prevent extra calls if cache is disabled let cacheKey = ''; - /** - * Emitted when the circuit breaker action is executed - * @event CircuitBreaker#fire - * @type {any} the arguments passed to the fired function - */ - this.emit('fire', args); - // If cache is enabled, check if we have a cached value if (this.options.cache) { cacheKey = this.options.cacheGetKey.apply(this, rest);