diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index 74854e882..44e483faf 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -30,18 +30,6 @@ function getWebpackChunkMap() { return v; } -async function promiseAllSettledBatched(tasks: (() => Promise)[], batchSize = 8): Promise { - const results: T[] = []; - for (let i = 0; i < tasks.length; i += batchSize) { - const batch = tasks.slice(i, i + batchSize); - const settled = await Promise.allSettled(batch.map(t => t())); - for (const r of settled) { - if (r.status === "fulfilled") results.push(r.value); - } - } - return results; -} - export async function loadLazyChunks() { const LazyChunkLoaderLogger = new Logger("LazyChunkLoader"); const queue = pLimit(50); @@ -73,7 +61,7 @@ export async function loadLazyChunks() { const shouldForceDefer = false; - await promiseAllSettledBatched(Array.from(lazyChunks).map(([, rawChunkIds, entryPoint]) => async () => { + await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => { const chunkIds = rawChunkIds ?.matchAll(Webpack.ChunkIdsRegex) .map(m => { @@ -124,9 +112,9 @@ export async function loadLazyChunks() { })); // Loads all found valid chunk groups - await promiseAllSettledBatched( + await Promise.all( Array.from(validChunkGroups) - .map(([chunkIds]) => () => + .map(([chunkIds]) => Promise.all(chunkIds.map(id => wreq.e(id))) ) ); @@ -202,7 +190,7 @@ export async function loadLazyChunks() { return !(validChunks.has(id) || invalidChunks.has(id)); }); - await promiseAllSettledBatched(chunksLeft.map(id => async () => queue(async () => { + await Promise.all(chunksLeft.map(async id => queue(async () => { const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) .then(t => /importScripts\(|self\.postMessage/.test(t));