From f4391e62917452f64f7e7d9177c8e8ae05cdd744 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 6 Jan 2026 16:09:59 +0100 Subject: [PATCH 1/7] move counters --- JetStreamDriver.js | 96 ++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 5aa1f1f8..d398a272 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -215,6 +215,17 @@ class BrowserFileLoader { // the global `fileLoader` cache. this.blobDataCache = { __proto__ : null }; this.loadCache = { __proto__ : null }; + this.counter = { + __proto__: null, + loadedResources: 0, + totalResources: 0, + failedPreloadResources: 0, + } + } + + get hasLoadedAllResources() { + return !this.counter.failedPreloadResources && ( + this.counter.loadedResources === this.counter.totalResources); } async doLoadBlob(resource) { @@ -287,10 +298,11 @@ class BrowserFileLoader { return promise; } + async retryPrefetchResource(type, prop, file) { console.assert(isInBrowser); - const counter = JetStream.counter; + const counter = browserFileLoader.counter; const blobData = this.blobDataCache[file]; if (blobData.blob) { // The same preload blob may be used by multiple subtests. Though the blob is already loaded, @@ -302,7 +314,7 @@ class BrowserFileLoader { counter.failedPreloadResources--; } } - return !counter.failedPreloadResources && counter.loadedResources == counter.totalResources; + return this.hasLoadedAllResources; } // Retry fetching the resource. @@ -320,7 +332,7 @@ class BrowserFileLoader { throw new Error("Fetch failed"); } - return !counter.failedPreloadResources && counter.loadedResources == counter.totalResources; + return this.hasLoadedAllResources; } free(files) { @@ -349,10 +361,6 @@ class Driver { this.benchmarks = Array.from(new Set(benchmarks)); this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1); console.assert(this.benchmarks.length, "No benchmarks selected"); - this.counter = { }; - this.counter.loadedResources = 0; - this.counter.totalResources = 0; - this.counter.failedPreloadResources = 0; } async start() { @@ -535,38 +543,33 @@ class Driver { async prefetchResources() { if (!isInBrowser) { - if (JetStreamParams.prefetchResources) { - await zlib.initialize(); - } - for (const benchmark of this.benchmarks) - benchmark.prefetchResourcesForShell(); - return; + await this.prefetchResourcesForShell(); + } else { + await this.prefetchResourcesForBrowser(); } + } + + async prefetchResourcesForShell() { + if (JetStreamParams.prefetchResources) { + await zlib.initialize(); + } + for (const benchmark of this.benchmarks) + benchmark.prefetchResourcesForShell(); + } + async prefetchResourcesForBrowser() { // TODO: Cleanup the browser path of the preloading below and in // `prefetchResourcesForBrowser` / `retryPrefetchResourcesForBrowser`. - const counter = JetStream.counter; const promises = []; for (const benchmark of this.benchmarks) - promises.push(benchmark.prefetchResourcesForBrowser(counter)); + promises.push(benchmark.prefetchResourcesForBrowser()); await Promise.all(promises); - if (counter.failedPreloadResources || counter.loadedResources != counter.totalResources) { - for (const benchmark of this.benchmarks) { - const allFilesLoaded = await benchmark.retryPrefetchResourcesForBrowser(counter); - if (allFilesLoaded) - break; - } - - if (counter.failedPreloadResources || counter.loadedResources != counter.totalResources) { - // If we've failed to prefetch resources even after a sequential 1 by 1 retry, - // then fail out early rather than letting subtests fail with a hang. - globalThis.allIsGood = false; - throw new Error("Fetch failed"); - } + if (!browserFileLoader.hasLoadedAllResources) { + await this.retryPrefetchResourcesForBrowser() } - JetStream.loadCache = { }; // Done preloading all the files. + browserFileLoader.loadCache = { }; // Done preloading all the files. const statusElement = document.getElementById("status"); statusElement.classList.remove('loading'); @@ -578,6 +581,22 @@ class Driver { } } + async retryPrefetchResourcesForBrowser() { + const counter = browserFileLoader.counter; + for (const benchmark of this.benchmarks) { + const allFilesLoaded = await benchmark.retryPrefetchResourcesForBrowser(); + if (allFilesLoaded) + break; + } + + if (!browserFileLoader.hasLoadedAllResources) { + // If we've failed to prefetch resources even after a sequential 1 by 1 retry, + // then fail out early rather than letting subtests fail with a hang. + globalThis.allIsGood = false; + throw new Error("Fetch failed"); + } + } + resultsObject(format = "run-benchmark") { switch(format) { case "run-benchmark": @@ -1117,13 +1136,14 @@ class Benchmark { updateCounter() { - const counter = JetStream.counter; + const counter = browserFileLoader.counter; ++counter.loadedResources; const statusElement = document.getElementById("status"); statusElement.innerHTML = `Loading ${counter.loadedResources} of ${counter.totalResources} ...`; } - prefetchResourcesForBrowser(counter) { + prefetchResourcesForBrowser() { + const counter = browserFileLoader.counter; console.assert(isInBrowser); const promises = this.plan.files.map((file) => browserFileLoader.loadBlob("file", null, file).then((blobData) => { @@ -1151,11 +1171,11 @@ class Benchmark { } } - JetStream.counter.totalResources += promises.length; + browserFileLoader.counter.totalResources += promises.length; return Promise.all(promises); } - async retryPrefetchResourcesForBrowser(counter) { + async retryPrefetchResourcesForBrowser() { // FIXME: Move to BrowserFileLoader. console.assert(isInBrowser); @@ -1173,7 +1193,7 @@ class Benchmark { return true; // All resources loaded, nothing more to do. } } - return !counter.failedPreloadResources && counter.loadedResources == counter.totalResources; + return !this.browserFileLoader.hasPendingResources } prefetchResourcesForShell() { @@ -1331,14 +1351,14 @@ class GroupedBenchmark extends Benchmark { this.benchmarks = benchmarks; } - async prefetchResourcesForBrowser(counter) { + async prefetchResourcesForBrowser() { for (const benchmark of this.benchmarks) - await benchmark.prefetchResourcesForBrowser(counter); + await benchmark.prefetchResourcesForBrowser(); } - async retryPrefetchResourcesForBrowser(counter) { + async retryPrefetchResourcesForBrowser() { for (const benchmark of this.benchmarks) - await benchmark.retryPrefetchResourcesForBrowser(counter); + await benchmark.retryPrefetchResourcesForBrowser(); } prefetchResourcesForShell() { From f5cd0cddde2c83b62b20b508487c92d1dd9a076f Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 6 Jan 2026 16:12:56 +0100 Subject: [PATCH 2/7] more-cleanup --- JetStreamDriver.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index d398a272..82713b57 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -1171,7 +1171,7 @@ class Benchmark { } } - browserFileLoader.counter.totalResources += promises.length; + counter.totalResources += promises.length; return Promise.all(promises); } @@ -1181,7 +1181,6 @@ class Benchmark { for (const resource of this.plan.files) { const allDone = await browserFileLoader.retryPrefetchResource("file", null, resource); - if (allDone) return true; // All resources loaded, nothing more to do. } @@ -1193,7 +1192,7 @@ class Benchmark { return true; // All resources loaded, nothing more to do. } } - return !this.browserFileLoader.hasPendingResources + return browserFileLoader.hasLoadedAllResources } prefetchResourcesForShell() { From 7676b756d70369cb829c1e86bdffaf877d77304c Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 6 Jan 2026 16:15:28 +0100 Subject: [PATCH 3/7] cleanup --- JetStreamDriver.js | 1 + 1 file changed, 1 insertion(+) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 82713b57..c11ef48f 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -357,6 +357,7 @@ class Driver { this.isReady = false; this.isDone = false; this.errors = []; + this.fileLoader = isInBrowser ? browserFileLoader : shellFileLoader; // Make benchmark list unique and sort it. this.benchmarks = Array.from(new Set(benchmarks)); this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1); From 3587f7702e744d4709aad762099466eef9a39f7d Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 6 Jan 2026 16:19:11 +0100 Subject: [PATCH 4/7] some-more-cleanup --- JetStreamDriver.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index c11ef48f..f9f7b571 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -543,10 +543,10 @@ class Driver { } async prefetchResources() { - if (!isInBrowser) { - await this.prefetchResourcesForShell(); - } else { + if (isInBrowser) { await this.prefetchResourcesForBrowser(); + } else { + await this.prefetchResourcesForShell(); } } From 1e3f4485ea66c8de41f0424392e9b4bcd67d1e68 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 6 Jan 2026 18:34:59 +0100 Subject: [PATCH 5/7] refactor --- JetStreamDriver.js | 266 +++++++++++++++++---------------------------- 1 file changed, 99 insertions(+), 167 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index f9f7b571..2aa60882 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -208,29 +208,66 @@ class ShellFileLoader { }; -class BrowserFileLoader { +const RETRY_COUNT = 3; +const RETRY_DELAY_MS = 500; +class BrowserFileLoader { constructor() { - // TODO: Cleanup / remove / merge `blobDataCache` and `loadCache` vs. - // the global `fileLoader` cache. - this.blobDataCache = { __proto__ : null }; - this.loadCache = { __proto__ : null }; + this._blobDataCache = { __proto__ : null }; this.counter = { __proto__: null, loadedResources: 0, totalResources: 0, - failedPreloadResources: 0, } } - get hasLoadedAllResources() { - return !this.counter.failedPreloadResources && ( - this.counter.loadedResources === this.counter.totalResources); + getBlobURL(file) { + const blobURL = this._blobDataCache[file].blobURL; + if (!blobURL) { + throw new Error(`Missing blob data for ${file}`); + } + return blobURL; + } + _updateCounter() { + ++this.counter.loadedResources; + JetStream.updateCounterUI(); } - async doLoadBlob(resource) { - const blobData = this.blobDataCache[resource]; + async prefetchResourceFile(file) { + return await this._prefetchResource(file); + } + async prefetchResourcePreload(name, resource) { + const blobData = await this._prefetchResource(resource); + if (!globalThis.allIsGood) + return; + return { name: name, resource: resource, blobURLOrPath: blobData.blobURL }; + } + + async _prefetchResource(resource) { + this.counter.totalResources++; + let blobDataOrPromise = this._blobDataCache[resource]; + if (!blobDataOrPromise) { + const newBlobData = { + resource: resource, + blob: null, + blobURL: null, + refCount: 0 + }; + blobDataOrPromise = this._loadBlob(newBlobData); + // Temporarily cache the loading promise. + this._blobDataCache[resource] = blobDataOrPromise; + } + const blobData = await blobDataOrPromise; + // Replace the potential promise in the cache. + this._blobDataCache[resource] = blobData; + if (globalThis.allIsGood) + this._updateCounter(); + return blobData; + } + + async _loadBlob(blobData) { + let resource = blobData.resource; const compressed = isCompressed(resource); if (compressed && !JetStreamParams.prefetchResources) { resource = uncompressedName(resource); @@ -244,7 +281,7 @@ class BrowserFileLoader { } let response; - let tries = 3; + let tries = RETRY_COUNT; while (tries--) { let hasError = false; try { @@ -254,8 +291,12 @@ class BrowserFileLoader { } if (!hasError && response.ok) break; - if (tries) + if (tries) { + await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS)); + console.warning(`Request failed, retrying: ${resource}`); continue; + } + globalThis.allIsGood = false; throw new Error("Fetch failed"); } @@ -266,85 +307,23 @@ class BrowserFileLoader { response = new Response(stream); } - let blob = await response.blob(); + const blob = await response.blob(); blobData.blob = blob; blobData.blobURL = URL.createObjectURL(blob); return blobData; } - async loadBlob(type, prop, resource, incrementRefCount = true) { - let blobData = this.blobDataCache[resource]; - if (!blobData) { - blobData = { - type: type, - prop: prop, - resource: resource, - blob: null, - blobURL: null, - refCount: 0 - }; - this.blobDataCache[resource] = blobData; - } - - if (incrementRefCount) - blobData.refCount++; - - let promise = this.loadCache[resource]; - if (promise) - return promise; - - promise = this.doLoadBlob(resource); - this.loadCache[resource] = promise; - return promise; - } - - - async retryPrefetchResource(type, prop, file) { - console.assert(isInBrowser); - - const counter = browserFileLoader.counter; - const blobData = this.blobDataCache[file]; - if (blobData.blob) { - // The same preload blob may be used by multiple subtests. Though the blob is already loaded, - // we still need to check if this subtest failed to load it before. If so, handle accordingly. - if (type == "preload") { - if (this.failedPreloads && this.failedPreloads[blobData.prop]) { - this.failedPreloads[blobData.prop] = false; - this.preloads.push({ name: blobData.prop, resource: blobData.resource, blobURLOrPath: blobData.blobURL }); - counter.failedPreloadResources--; - } - } - return this.hasLoadedAllResources; - } - - // Retry fetching the resource. - this.loadCache[file] = null; - await this.loadBlob(type, prop, file, false).then((blobData) => { - if (!globalThis.allIsGood) - return; - if (blobData.type == "preload") - this.preloads.push({ name: blobData.prop, resource: blobData.resource, blobURLOrPath: blobData.blobURL }); - this.updateCounter(); - }); - - if (!blobData.blob) { - globalThis.allIsGood = false; - throw new Error("Fetch failed"); - } - - return this.hasLoadedAllResources; - } - free(files) { for (const file of files) { - const blobData = this.blobDataCache[file]; + const blobData = this._blobDataCache[file]; // If we didn't prefetch this resource, then no need to free it if (!blobData.blob) { continue } blobData.refCount--; - if (!blobData.refCount) - this.blobDataCache[file] = undefined; + if (!blobData.refCount) { + this._blobDataCache[file] = undefined; + } } } } @@ -388,10 +367,8 @@ class Driver { performance.mark("update-ui"); benchmark.updateUIAfterRun(); + benchmark.tearDown(); - if (isInBrowser) { - browserFileLoader.free(benchmark.files); - } } performance.measure("runner update-ui", "update-ui-start"); @@ -560,18 +537,12 @@ class Driver { async prefetchResourcesForBrowser() { // TODO: Cleanup the browser path of the preloading below and in - // `prefetchResourcesForBrowser` / `retryPrefetchResourcesForBrowser`. + // `prefetchResourcesForBrowser`. const promises = []; for (const benchmark of this.benchmarks) promises.push(benchmark.prefetchResourcesForBrowser()); await Promise.all(promises); - if (!browserFileLoader.hasLoadedAllResources) { - await this.retryPrefetchResourcesForBrowser() - } - - browserFileLoader.loadCache = { }; // Done preloading all the files. - const statusElement = document.getElementById("status"); statusElement.classList.remove('loading'); statusElement.innerHTML = `Start Test`; @@ -582,20 +553,10 @@ class Driver { } } - async retryPrefetchResourcesForBrowser() { + updateCounterUI() { const counter = browserFileLoader.counter; - for (const benchmark of this.benchmarks) { - const allFilesLoaded = await benchmark.retryPrefetchResourcesForBrowser(); - if (allFilesLoaded) - break; - } - - if (!browserFileLoader.hasLoadedAllResources) { - // If we've failed to prefetch resources even after a sequential 1 by 1 retry, - // then fail out early rather than letting subtests fail with a hang. - globalThis.allIsGood = false; - throw new Error("Fetch failed"); - } + const statusElement = document.getElementById("status"); + statusElement.innerHTML = `Loading ${counter.loadedResources} of ${counter.totalResources} ...`; } resultsObject(format = "run-benchmark") { @@ -846,6 +807,9 @@ class ShellScripts extends Scripts { } add(text) { + if (!text) { + throw new Error("Missing script source"); + } this.scripts.push(text); } @@ -878,10 +842,16 @@ class BrowserScripts extends Scripts { } add(text) { + if (!text) { + throw new Error("Missing script source"); + } this.scripts.push(``); } addWithURL(url) { + if (!url) { + throw new Error("Missing script url"); + } this.scripts.push(``); } } @@ -914,6 +884,7 @@ class Benchmark { get name() { return this.plan.name; } get files() { return this.plan.files; } + get preloadFiles() { return Object.values(this.plan.preload ?? {}); } get isDone() { return this._state == BenchmarkState.DONE || this._state == BenchmarkState.ERROR; @@ -1080,13 +1051,12 @@ class Benchmark { scripts.add(prerunCode); if (!isInBrowser) { - console.assert(this.scripts && this.scripts.length === this.plan.files.length); + console.assert(this.scripts && this.scripts.length === this.files.length); for (const text of this.scripts) scripts.add(text); } else { - const cache = browserFileLoader.blobDataCache; - for (const file of this.plan.files) { - scripts.addWithURL(cache[file].blobURL); + for (const file of this.files) { + scripts.addWithURL(browserFileLoader.getBlobURL(file)); } } @@ -1136,64 +1106,18 @@ class Benchmark { } - updateCounter() { - const counter = browserFileLoader.counter; - ++counter.loadedResources; - const statusElement = document.getElementById("status"); - statusElement.innerHTML = `Loading ${counter.loadedResources} of ${counter.totalResources} ...`; - } - - prefetchResourcesForBrowser() { - const counter = browserFileLoader.counter; + async prefetchResourcesForBrowser() { console.assert(isInBrowser); - - const promises = this.plan.files.map((file) => browserFileLoader.loadBlob("file", null, file).then((blobData) => { - if (!globalThis.allIsGood) - return; - this.updateCounter(); - }).catch((error) => { - // We'll try again later in retryPrefetchResourceForBrowser(). Don't throw an error. - })); - - if (this.plan.preload) { - for (const [name, resource] of Object.entries(this.plan.preload)) { - promises.push(browserFileLoader.loadBlob("preload", name, resource).then((blobData) => { - if (!globalThis.allIsGood) - return; - this.preloads.push({ name: blobData.prop, resource: blobData.resource, blobURLOrPath: blobData.blobURL }); - this.updateCounter(); - }).catch((error) => { - // We'll try again later in retryPrefetchResourceForBrowser(). Don't throw an error. - if (!this.failedPreloads) - this.failedPreloads = { }; - this.failedPreloads[name] = true; - counter.failedPreloadResources++; - })); - } + const promises = this.files.map((file) => browserFileLoader.prefetchResourceFile(file)); + for (const [name, resource] of Object.entries(this.plan.preload ?? {})) { + promises.push(this.prefetchResourcePreload(name, resource)); } - - counter.totalResources += promises.length; - return Promise.all(promises); + await Promise.all(promises); } - async retryPrefetchResourcesForBrowser() { - // FIXME: Move to BrowserFileLoader. - console.assert(isInBrowser); - - for (const resource of this.plan.files) { - const allDone = await browserFileLoader.retryPrefetchResource("file", null, resource); - if (allDone) - return true; // All resources loaded, nothing more to do. - } - - if (this.plan.preload) { - for (const [name, resource] of Object.entries(this.plan.preload)) { - const allDone = await browserFileLoader.retryPrefetchResource("preload", name, resource); - if (allDone) - return true; // All resources loaded, nothing more to do. - } - } - return browserFileLoader.hasLoadedAllResources + async prefetchResourcePreload(name, resource) { + const preloadData = await browserFileLoader.prefetchResourcePreload(name, resource); + this.preloads.push(preloadData); } prefetchResourcesForShell() { @@ -1201,7 +1125,7 @@ class Benchmark { console.assert(!isInBrowser); console.assert(this.scripts === null, "This initialization should be called only once."); - this.scripts = this.plan.files.map(file => shellFileLoader.load(file)); + this.scripts = this.files.map(file => shellFileLoader.load(file)); console.assert(this.preloads.length === 0, "This initialization should be called only once."); this.shellPrefetchedResources = Object.create(null); @@ -1337,6 +1261,13 @@ class Benchmark { } plotContainer.innerHTML = `${circlesSVG}`; } + + tearDown() { + if (isInBrowser) { + browserFileLoader.free(this.files); + browserFileLoader.free(this.preloadFiles); + } + } }; class GroupedBenchmark extends Benchmark { @@ -1356,11 +1287,6 @@ class GroupedBenchmark extends Benchmark { await benchmark.prefetchResourcesForBrowser(); } - async retryPrefetchResourcesForBrowser() { - for (const benchmark of this.benchmarks) - await benchmark.retryPrefetchResourcesForBrowser(); - } - prefetchResourcesForShell() { for (const benchmark of this.benchmarks) benchmark.prefetchResourcesForShell(); @@ -1424,6 +1350,12 @@ class GroupedBenchmark extends Benchmark { this._state = BenchmarkState.DONE; } + tearDown() { + for (const benchmark of this.benchmarks) { + benchmark.tearDown(); + } + } + processResults() { this.results = []; for (const benchmark of this.benchmarks) From 31254a5a2a168201e773470aadc212005c7326d0 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 13 Jan 2026 17:57:00 +0100 Subject: [PATCH 6/7] fix-delete --- JetStreamDriver.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 2aa60882..2729c0e9 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -233,18 +233,14 @@ class BrowserFileLoader { JetStream.updateCounterUI(); } - async prefetchResourceFile(file) { - return await this._prefetchResource(file); - } - async prefetchResourcePreload(name, resource) { - const blobData = await this._prefetchResource(resource); + const blobData = await this.prefetchResourceFile(resource); if (!globalThis.allIsGood) return; return { name: name, resource: resource, blobURLOrPath: blobData.blobURL }; } - async _prefetchResource(resource) { + async prefetchResourceFile(resource) { this.counter.totalResources++; let blobDataOrPromise = this._blobDataCache[resource]; if (!blobDataOrPromise) { @@ -259,10 +255,11 @@ class BrowserFileLoader { this._blobDataCache[resource] = blobDataOrPromise; } const blobData = await blobDataOrPromise; - // Replace the potential promise in the cache. - this._blobDataCache[resource] = blobData; if (globalThis.allIsGood) this._updateCounter(); + // Replace the potential promise in the cache. + this._blobDataCache[resource] = blobData; + blobData.refCount++; return blobData; } @@ -323,6 +320,7 @@ class BrowserFileLoader { blobData.refCount--; if (!blobData.refCount) { this._blobDataCache[file] = undefined; + console.log("DELETING", file); } } } @@ -336,7 +334,6 @@ class Driver { this.isReady = false; this.isDone = false; this.errors = []; - this.fileLoader = isInBrowser ? browserFileLoader : shellFileLoader; // Make benchmark list unique and sort it. this.benchmarks = Array.from(new Set(benchmarks)); this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1); From 396449e5daf741ada4b46bd3a789530401c10cd7 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 13 Jan 2026 18:17:36 +0100 Subject: [PATCH 7/7] formatting --- JetStreamDriver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 2729c0e9..546d8f07 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -255,11 +255,11 @@ class BrowserFileLoader { this._blobDataCache[resource] = blobDataOrPromise; } const blobData = await blobDataOrPromise; - if (globalThis.allIsGood) - this._updateCounter(); // Replace the potential promise in the cache. this._blobDataCache[resource] = blobData; blobData.refCount++; + if (globalThis.allIsGood) + this._updateCounter(); return blobData; }