Skip to content

Commit

Permalink
Reduce job queue shutdown timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Apr 5, 2023
1 parent 4a18667 commit c5dda1d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ts/background.ts
Expand Up @@ -740,11 +740,13 @@ export async function startApp(): Promise<void> {
sleeper.shutdown();

const shutdownQueues = async () => {
log.info('background/shutdown: shutting down queues');
await Promise.allSettled([
StartupQueue.shutdown(),
shutdownAllJobQueues(),
]);

log.info('background/shutdown: shutting down conversation queues');
await Promise.allSettled(
window.ConversationController.getAll().map(async convo => {
try {
Expand All @@ -757,9 +759,11 @@ export async function startApp(): Promise<void> {
}
})
);

log.info('background/shutdown: all queues shutdown');
};

// wait for at most 2 minutes for startup queue and job queues to drain
// wait for at most 1 minutes for startup queue and job queues to drain
let timeout: NodeJS.Timeout | undefined;
await Promise.race([
shutdownQueues(),
Expand All @@ -770,7 +774,7 @@ export async function startApp(): Promise<void> {
);
timeout = undefined;
resolve();
}, 2 * MINUTE);
}, 1 * MINUTE);
}),
]);
if (timeout) {
Expand Down

0 comments on commit c5dda1d

Please sign in to comment.