Job Queue: Don't wait unless it's our first time in verify loop
This commit is contained in:
parent
a013e43299
commit
8f630a52b5
5 changed files with 13 additions and 0 deletions
|
@ -214,8 +214,11 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
|
|||
|
||||
let timeRemaining: number;
|
||||
let shouldContinue: boolean;
|
||||
let count = 0;
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
count += 1;
|
||||
log.info('calculating timeRemaining and shouldContinue...');
|
||||
timeRemaining = timestamp + MAX_RETRY_TIME - Date.now();
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
|
@ -223,6 +226,7 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
|
|||
attempt,
|
||||
log,
|
||||
timeRemaining,
|
||||
skipWait: count > 1,
|
||||
});
|
||||
if (!shouldContinue) {
|
||||
break;
|
||||
|
|
|
@ -11,10 +11,12 @@ export async function commonShouldJobContinue({
|
|||
attempt,
|
||||
log,
|
||||
timeRemaining,
|
||||
skipWait,
|
||||
}: Readonly<{
|
||||
attempt: number;
|
||||
log: LoggerType;
|
||||
timeRemaining: number;
|
||||
skipWait: boolean;
|
||||
}>): Promise<boolean> {
|
||||
if (timeRemaining <= 0) {
|
||||
log.info("giving up because it's been too long");
|
||||
|
@ -37,6 +39,10 @@ export async function commonShouldJobContinue({
|
|||
return false;
|
||||
}
|
||||
|
||||
if (skipWait) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const sleepTime = exponentialBackoffSleepTime(attempt);
|
||||
log.info(`sleeping for ${sleepTime}`);
|
||||
await sleep(sleepTime);
|
||||
|
|
|
@ -29,6 +29,7 @@ export async function runReceiptJob({
|
|||
attempt,
|
||||
log,
|
||||
timeRemaining,
|
||||
skipWait: false,
|
||||
});
|
||||
if (!shouldContinue) {
|
||||
return;
|
||||
|
|
|
@ -108,6 +108,7 @@ export async function runSyncJob({
|
|||
attempt,
|
||||
log,
|
||||
timeRemaining,
|
||||
skipWait: false,
|
||||
});
|
||||
if (!shouldContinue) {
|
||||
return;
|
||||
|
|
|
@ -54,6 +54,7 @@ export class SingleProtoJobQueue extends JobQueue<SingleProtoJobData> {
|
|||
attempt,
|
||||
log,
|
||||
timeRemaining,
|
||||
skipWait: false,
|
||||
});
|
||||
if (!shouldContinue) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue