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 timeRemaining: number;
|
||||||
let shouldContinue: boolean;
|
let shouldContinue: boolean;
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
|
count += 1;
|
||||||
log.info('calculating timeRemaining and shouldContinue...');
|
log.info('calculating timeRemaining and shouldContinue...');
|
||||||
timeRemaining = timestamp + MAX_RETRY_TIME - Date.now();
|
timeRemaining = timestamp + MAX_RETRY_TIME - Date.now();
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
@ -223,6 +226,7 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
|
||||||
attempt,
|
attempt,
|
||||||
log,
|
log,
|
||||||
timeRemaining,
|
timeRemaining,
|
||||||
|
skipWait: count > 1,
|
||||||
});
|
});
|
||||||
if (!shouldContinue) {
|
if (!shouldContinue) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -11,10 +11,12 @@ export async function commonShouldJobContinue({
|
||||||
attempt,
|
attempt,
|
||||||
log,
|
log,
|
||||||
timeRemaining,
|
timeRemaining,
|
||||||
|
skipWait,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
attempt: number;
|
attempt: number;
|
||||||
log: LoggerType;
|
log: LoggerType;
|
||||||
timeRemaining: number;
|
timeRemaining: number;
|
||||||
|
skipWait: boolean;
|
||||||
}>): Promise<boolean> {
|
}>): Promise<boolean> {
|
||||||
if (timeRemaining <= 0) {
|
if (timeRemaining <= 0) {
|
||||||
log.info("giving up because it's been too long");
|
log.info("giving up because it's been too long");
|
||||||
|
@ -37,6 +39,10 @@ export async function commonShouldJobContinue({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skipWait) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const sleepTime = exponentialBackoffSleepTime(attempt);
|
const sleepTime = exponentialBackoffSleepTime(attempt);
|
||||||
log.info(`sleeping for ${sleepTime}`);
|
log.info(`sleeping for ${sleepTime}`);
|
||||||
await sleep(sleepTime);
|
await sleep(sleepTime);
|
||||||
|
|
|
@ -29,6 +29,7 @@ export async function runReceiptJob({
|
||||||
attempt,
|
attempt,
|
||||||
log,
|
log,
|
||||||
timeRemaining,
|
timeRemaining,
|
||||||
|
skipWait: false,
|
||||||
});
|
});
|
||||||
if (!shouldContinue) {
|
if (!shouldContinue) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -108,6 +108,7 @@ export async function runSyncJob({
|
||||||
attempt,
|
attempt,
|
||||||
log,
|
log,
|
||||||
timeRemaining,
|
timeRemaining,
|
||||||
|
skipWait: false,
|
||||||
});
|
});
|
||||||
if (!shouldContinue) {
|
if (!shouldContinue) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -54,6 +54,7 @@ export class SingleProtoJobQueue extends JobQueue<SingleProtoJobData> {
|
||||||
attempt,
|
attempt,
|
||||||
log,
|
log,
|
||||||
timeRemaining,
|
timeRemaining,
|
||||||
|
skipWait: false,
|
||||||
});
|
});
|
||||||
if (!shouldContinue) {
|
if (!shouldContinue) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue