Skip to content

Commit

Permalink
fix: disabled breaker emits fire events
Browse files Browse the repository at this point in the history
To revert to previous behaviour up to v8.1.4.

nodeshift#894
  • Loading branch information
ullumullu committed Oct 25, 2024
1 parent 3350332 commit 7443217
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 7443217

Please sign in to comment.