fix "unhandled rejection" error when a queue fails to update

This commit is contained in:
Hazelnoot 2025-06-25 22:26:43 -04:00
parent 7ca90502d1
commit f8814483e8
2 changed files with 5 additions and 3 deletions

View file

@ -254,7 +254,7 @@ export class CollapsedQueueService implements OnApplicationShutdown {
const results = await queue.performAllNow();
const [succeeded, failed] = results.reduce((counts, result) => {
counts[result.status === 'fulfilled' ? 0 : 1]++;
counts[result ? 0 : 1]++;
return counts;
}, [0, 0]);

View file

@ -99,7 +99,7 @@ export class CollapsedQueue<V> {
const entries = Array.from(this.jobs.entries());
this.jobs.clear();
return await Promise.allSettled(entries.map(([key, job]) => this._perform(key, job.value)));
return await Promise.all(entries.map(([key, job]) => this._perform(key, job.value)));
}
private async _perform(key: string, value: V) {
@ -113,9 +113,11 @@ export class CollapsedQueue<V> {
} else {
await this.perform(key, value);
}
return true;
} catch (err) {
await this.opts?.onError?.(this, err);
throw err;
return false;
}
}