From df197d4994de94c68450f66f047e262c0b0ebafd Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 19 Mar 2026 08:12:03 -0400 Subject: [PATCH] LoadLazyChunks: Retry --- src/debug/loadLazyChunks.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index 32ab77041..78eeaa6f9 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -96,9 +96,18 @@ export async function loadLazyChunks() { if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; - const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) - .then(r => r.text()) - .then(t => /importScripts\(|self\.postMessage/.test(t)); + let isWorkerAsset = false; + for (let attempt = 0; attempt < 3; attempt++) { + try { + isWorkerAsset = await fetch(wreq.p + wreq.u(id)) + .then(r => r.text()) + .then(t => /importScripts\(|self\.postMessage/.test(t)); + break; + } catch (err) { + if (attempt === 2) throw err; + await new Promise(resolve => setTimeout(resolve, 500 * (attempt + 1))); + } + } if (isWorkerAsset) { invalidChunks.add(id); @@ -195,9 +204,18 @@ export async function loadLazyChunks() { }); await promiseAllSettledBatched(chunksLeft.map(id => async () => { - const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) - .then(r => r.text()) - .then(t => /importScripts\(|self\.postMessage/.test(t)); + let isWorkerAsset = false; + for (let attempt = 0; attempt < 3; attempt++) { + try { + isWorkerAsset = await fetch(wreq.p + wreq.u(id)) + .then(r => r.text()) + .then(t => /importScripts\(|self\.postMessage/.test(t)); + break; + } catch (err) { + if (attempt === 2) throw err; + await new Promise(resolve => setTimeout(resolve, 500 * (attempt + 1))); + } + } // Loads the chunk. Currently this only happens with the language packs which are loaded differently if (!isWorkerAsset) {