Skip to content

Commit

Permalink
push.apply with an unbounded array leads to stack overflow exceptions.
Browse files Browse the repository at this point in the history
fix for #827
  • Loading branch information
jdmarshall committed Oct 26, 2023
1 parent d644f10 commit 2658da8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ class CircuitBreaker extends EventEmitter {

// If cache is enabled, check if we have a cached value
if (this.options.cache) {
cacheKey = this.options.cacheGetKey.apply(this, rest);
cacheKey = this.options.cacheGetKey(...rest);
const cached = this.options.cacheTransport.get(cacheKey);
if (cached) {
/**
Expand Down Expand Up @@ -823,8 +823,8 @@ function fallback (circuit, err, args) {
if (circuit[FALLBACK_FUNCTION]) {
try {
const result =
circuit[FALLBACK_FUNCTION]
.apply(circuit[FALLBACK_FUNCTION], [...args, err]);
circuit[FALLBACK_FUNCTION](...args, err);

/**
* Emitted when the circuit breaker executes a fallback function
* @event CircuitBreaker#fallback
Expand Down
4 changes: 3 additions & 1 deletion lib/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class Status extends EventEmitter {
});

if (this.rollingPercentilesEnabled) {
acc.latencyTimes.push.apply(acc.latencyTimes, val.latencyTimes || []);
if (val.latencyTimes) {
acc.latencyTimes = acc.latencyTimes.concat(val.latencyTimes);
}
}
return acc;
}, bucket());
Expand Down

0 comments on commit 2658da8

Please sign in to comment.