in src/common-amqp/amqp_cbs.ts [346:372]
private _removeExpiredPutTokens(): void {
const currentTime = Math.round(Date.now() / 1000);
const expiredPutTokens: PutTokenOperation[] = [];
while (this._putToken.outstandingPutTokens.length > 0) {
//
// The timeouts in this array by definition are monotonically increasing. We will be done looking if we
// hit one that is not yet expired.
//
/*Codes_SRS_NODE_AMQP_CBS_16_014: [The `putToken` method will time out the put token operation if no response is returned within a configurable number of seconds.]*/
if (this._putToken.outstandingPutTokens[0].expirationTime < currentTime) {
expiredPutTokens.push(this._putToken.outstandingPutTokens[0]);
this._putToken.outstandingPutTokens.splice(0, 1);
} else {
break;
}
}
expiredPutTokens.forEach((currentExpiredPut) => {
/*Codes_SRS_NODE_AMQP_CBS_16_015: [The `putToken` method will invoke the `callback` (if supplied) with an error object if the put token operation timed out.]*/
currentExpiredPut.putTokenCallback(new errors.TimeoutError('Put Token operation had no response within ' + this._putToken.numberOfSecondsToTimeout));
});
//
// If there are any putTokens left keep trying to time them out.
//
if (this._putToken.outstandingPutTokens.length > 0) {
this._putToken.timeoutTimer = setTimeout(this._removeExpiredPutTokens.bind(this), this._putToken.putTokenTimeOutExaminationInterval);
}
}