Skip to content

Commit

Permalink
BREAK-8: add connection-failed event
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Jun 10, 2024
1 parent cdfacd2 commit add9193
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/CircuitBreaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export class CircuitBreaker extends EventEmitter {
}

async _evaluate() {
this._evaluatingPromiseHook = Promise.allSettled(this._probes.map(p => p.check()));
this._evaluatingPromiseHook = Promise.allSettled(this._probes.map(p => p.check().catch(error => {
this.emit('connection-failed', error);
return 'failed';
})));
await this._evaluatingPromiseHook;
this._evaluatingPromiseHook = null;

Expand Down

0 comments on commit add9193

Please sign in to comment.