in glean/src/core/upload/manager.ts [250:289]
private getUploadTaskInternal(): UploadTask {
if (this.recoverableFailureCount >= this.policy.maxRecoverableFailures) {
log(
UPLOAD_MANAGER_LOG_TAG,
"Glean has reached maximum recoverable upload failures for the current uploading window.",
LoggingLevel.Debug
);
return uploadTaskFactory.done();
}
if (this.queue.length > 0) {
const { state, remainingTime } = this.rateLimiter.getState();
if (state === RateLimiterState.Throttled) {
log(
UPLOAD_MANAGER_LOG_TAG,
[
"Glean is currently throttled.",
`Pending pings may be uploaded in ${(remainingTime || 0) / 1000}s.`
],
LoggingLevel.Debug
);
this.waitAttemptCount++;
if (this.waitAttemptCount > this.policy.maxWaitAttempts) {
return uploadTaskFactory.done();
}
return uploadTaskFactory.wait(remainingTime || 0);
}
// We are sure this array is not empty, so this will never return an `undefined` value.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const nextPing = this.queue.shift()!;
this.processing.add(nextPing.identifier);
return uploadTaskFactory.upload(nextPing);
}
return uploadTaskFactory.done();
}