diff --git a/packages/puppeteer-core/src/common/HandleIterator.ts b/packages/puppeteer-core/src/common/HandleIterator.ts index a7a3f0f3cdf..d5df382f881 100644 --- a/packages/puppeteer-core/src/common/HandleIterator.ts +++ b/packages/puppeteer-core/src/common/HandleIterator.ts @@ -29,7 +29,7 @@ const DEFAULT_BATCH_SIZE = 20; */ async function* fastTransposeIteratorHandle( iterator: JSHandle>, - size = DEFAULT_BATCH_SIZE + size: number ) { const array = await iterator.evaluateHandle(async (iterator, size) => { const results = []; @@ -56,8 +56,11 @@ async function* fastTransposeIteratorHandle( async function* transposeIteratorHandle( iterator: JSHandle> ) { + let size = DEFAULT_BATCH_SIZE; try { - while (!(yield* fastTransposeIteratorHandle(iterator))) {} + while (!(yield* fastTransposeIteratorHandle(iterator, size))) { + size <<= 1; + } } finally { await iterator.dispose(); }