Skip to content

Commit e3a87b3

Browse files
chore: remove eager prediction of overflow
1 parent 811474e commit e3a87b3

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

src/helpers/collectCursorUntilMaxBytes.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,12 @@ export async function collectCursorUntilMaxBytesLimit<T = unknown>({
7474

7575
let wasCapped: boolean = false;
7676
let totalBytes = 0;
77-
let biggestDocSizeSoFar = 0;
7877
const bufferedDocuments: T[] = [];
7978
while (true) {
8079
if (abortSignal?.aborted) {
8180
break;
8281
}
8382

84-
// This is an eager attempt to validate that fetching the next document
85-
// won't exceed the applicable limit.
86-
if (totalBytes + biggestDocSizeSoFar >= maxBytesPerQuery) {
87-
wasCapped = true;
88-
break;
89-
}
90-
9183
// If the cursor is empty then there is nothing for us to do anymore.
9284
const nextDocument = await cursor.tryNext();
9385
if (!nextDocument) {
@@ -101,7 +93,6 @@ export async function collectCursorUntilMaxBytesLimit<T = unknown>({
10193
}
10294

10395
totalBytes += nextDocumentSize;
104-
biggestDocSizeSoFar = Math.max(biggestDocSizeSoFar, nextDocumentSize);
10596
bufferedDocuments.push(nextDocument);
10697
}
10798

0 commit comments

Comments
 (0)