diff --git a/lib/sinon/proxy-invoke.js b/lib/sinon/proxy-invoke.js index 1b120ece5..844c6edbf 100644 --- a/lib/sinon/proxy-invoke.js +++ b/lib/sinon/proxy-invoke.js @@ -10,10 +10,12 @@ const ErrorConstructor = Error.prototype.constructor; const bind = Function.prototype.bind; let callId = 0; +const maxSafeInteger = Number.MAX_SAFE_INTEGER; module.exports = function invoke(func, thisValue, args) { const matchings = this.matchingFakes(args); - const currentCallId = callId++; + const currentCallId = callId; + callId = callId === maxSafeInteger ? 0 : callId + 1; let exception, returnValue; proxyCallUtil.incrementCallCount(this);