Skip to content

Commit f8b55c9

Browse files
committed
drain all at once
1 parent 9d05ae5 commit f8b55c9

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

packages/core/src/utils/promisebuffer.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ export function makePromiseBuffer<T>(limit: number = 100): PromiseBuffer<T> {
5656
return task;
5757
}
5858

59-
function _drainNextSyncPromise(): PromiseLike<boolean> {
60-
const item = buffer.values().next().value as PromiseLike<T>;
61-
62-
if (!item) {
63-
return resolvedSyncPromise(true);
64-
}
65-
66-
return item.then(() => {
67-
return _drainNextSyncPromise();
68-
});
69-
}
70-
7159
/**
7260
* Wait for all promises in the queue to resolve or for timeout to expire, whichever comes first.
7361
*
@@ -82,7 +70,7 @@ export function makePromiseBuffer<T>(limit: number = 100): PromiseBuffer<T> {
8270
return resolvedSyncPromise(true);
8371
}
8472

85-
const drainPromise = _drainNextSyncPromise();
73+
const drainPromise = Promise.all(Array.from(buffer)).then(() => true);
8674

8775
if (!timeout) {
8876
return drainPromise;

0 commit comments

Comments
 (0)