diff --git a/lib/utils/sequential-promise-resolver.js b/lib/utils/sequential-promise-resolver.js index 0ea746b81..ad88644ef 100644 --- a/lib/utils/sequential-promise-resolver.js +++ b/lib/utils/sequential-promise-resolver.js @@ -1,37 +1,39 @@ // @flow +import { ignorePromiseRejections } from './promises.js'; + class SequentialPromiseResolver { onResolve: Result => Promise; promises: Array> = []; currentlySpinning: boolean = false; constructor(onResolve: Result => Promise) { this.onResolve = onResolve; } add(promise: Promise) { this.promises.push(promise); - this.spinPromises(); + ignorePromiseRejections(this.spinPromises()); } async spinPromises() { if (this.currentlySpinning) { return; } this.currentlySpinning = true; let currentPromise = this.promises.shift(); while (currentPromise) { // It's important that we await in sequence here as the messages must be // delivered in order. For more context, see https://phab.comm.dev/D355 const result = await currentPromise; if (result) { await this.onResolve(result); } currentPromise = this.promises.shift(); } this.currentlySpinning = false; } } export default SequentialPromiseResolver;