You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On an unstable connection, one failed download out of the ~100–200 at startup broke the app. The .NET loader retries only when a request fails before the response headers arrive; a connection reset mid-body failed startup, and nothing timed out, so a stalled response hung it forever.
Downloads (ResourceLoader.ts) go through the runtime's withResourceLoader hook. Each one gets a headers timeout (20 s) and an idle watchdog (8 s without bytes). Failures (network errors, mid-body resets, 5xx/408/429, stalls) are retried with jittered exponential backoff, up to 8 attempts, and wait for online while the browser reports offline. Subresource integrity is checked after the download, since fetch({ integrity }) exposes no bytes until the body is complete, which would hide a stall.
dotnet.native.wasm: after the verified download, the runtime gets a force-cache response for the same URL. The browser only reuses compiled WebAssembly (its code cache) for a fetched response, not one built from a buffer. Hosts sending no-store keep the buffered copy.
The runtime's own JS modules (dotnet.runtime, dotnet.native) are imported in onConfigLoaded, which the runtime awaits, so its later import() resolves from the module map. A failed import stays in the module map, so retries use ?r=N, and loadBootResource hands the runtime the URL that worked. blob: URLs don't work, because emscripten resolves paths against import.meta.url. A stalled import() can't be aborted, so it's abandoned after the headers timeout.
uno-config.js, dotnet.js, and the require.js dependencies, including AppManifest.js, are retried the same way.
DOMContentLoaded: the bootstrapper only called preInit() from a listener for it. When uno-bootstrap.js was imported after the document was parsed, the loader was never set up, and the first progress report threw Cannot set properties of undefined (setting 'max').
Timeouts and attempts can be overridden with UNO_BOOTSTRAP_FETCH_HEADERS_TIMEOUT_MS, _IDLE_TIMEOUT_MS and _MAX_ATTEMPTS. Docs: new "Resilient loading" page.
Not covered: the files index.html references directly (require.js, uno-bootstrap.js, stylesheets) are loaded by the browser. #1097 makes the stylesheets non-blocking.
Validation
New Uno.Wasm.Tests.ResilientLoading (CI, linux): a server fails the first request of every boot resource, rotating through a reset mid-body, a stall and a 503, and also serves late.html, which imports uno-bootstrap.js after load. The RayTracer must start on both.
Before: the first fault (uno-config.js) fails startup; late.html never starts.
After: both start, with 21 faults injected; stalls account for most of the ~38 s.
On a Uno 7.0 template app, through a test server simulating 4G with injected faults (cold loads, all PRs of this series combined):
Faults
Before
After
One network handover (every connection drops once)
Cold load speed without faults is unchanged (10.70 s vs 10.70 s median, n=5). The remaining failures under the harshest profile come from fetches made later by the app itself (Uno's uno-assets.txt manifest), which unoplatform/uno needs to make resilient as well.
Object-form resource manifests can store the fingerprinted filename in each value's name field. Returning only the keys here preloads a logical/nonexistent URL and can exhaust all retries before startup on that supported manifest format. Match the extraction already used in Embedded/service-worker.js:108-120.
Fail when module-script replacement does not occur
If the published index.html markup changes so this regex no longer matches, replace() returns the original page and /late.html becomes a normal startup. The late-import test then passes without exercising the DOMContentLoaded regression. Fail explicitly when no module-script replacement was made.
Apply resilient loading to the WebWorker bootstrapper
doc/features-resilient-loading.md:11
This coverage claim excludes the supported WebWorker mode without saying so. WorkerBootstrapper.ts still fetches uno-config.js, imports dotnet.js, and configures the runtime without withResourceLoader, so worker startup retains the original no-retry/no-timeout failure modes. Integrate the resilient loader into the separately compiled worker bootstrapper, or document WebWorker mode as an explicit limitation.
The .NET loader retries a download only when it fails before the response
headers arrive, and nothing has a timeout. On an unstable connection, a
connection reset mid-body fails startup, and a response that stops sending
bytes hangs it forever. The runtime's own JS module imports, uno-config.js,
dotnet.js and the require.js dependencies had no retry at all.
Route the runtime's resources through withResourceLoader with a headers
timeout, an idle watchdog and a jittered exponential backoff that waits for
the browser to be back online. SRI is verified after the download, since
fetch({ integrity }) exposes no bytes until the body is complete. Module
imports are retried with a distinct URL, as a failed import stays in the
module map, and time out since import() can't be aborted. The runtime's JS
modules are imported in onConfigLoaded, which the runtime awaits, and
loadBootResource hands it the URL that succeeded.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N5azy6DU7ujLte16VPVYQs
The resilient download builds a Response from a buffer, which the browser
can't match to its WebAssembly code cache. Once downloaded and verified, the
file is in the HTTP cache: fetch it again from there (force-cache) and hand
that response to the runtime. Hosts that send no-store keep the buffered
copy.
Measured on a Uno 7.0 app, simulated 4G, warm reload (median, n=5): 3.37 s,
against 3.22 s when the runtime fetches dotnet.native.wasm itself (without
retries) and 3.53 s for the shipped bootstrapper.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N5azy6DU7ujLte16VPVYQs
- Look dotnet.native.wasm up in the HTTP cache with only-if-cached, so the
lookup can't go back to the network and stall.
- Report a dependency's final failure through requirejs.onError instead of
only logging it.
- Let the browser verify integrity where crypto.subtle is unavailable,
instead of skipping the check.
- Read the fingerprinted name of object-shaped runtime module entries.
- Spell out the full environment variable names.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ADrzrqtw3RQdHan77rypBM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1091
What changed
On an unstable connection, one failed download out of the ~100–200 at startup broke the app. The .NET loader retries only when a request fails before the response headers arrive; a connection reset mid-body failed startup, and nothing timed out, so a stalled response hung it forever.
ResourceLoader.ts) go through the runtime'swithResourceLoaderhook. Each one gets a headers timeout (20 s) and an idle watchdog (8 s without bytes). Failures (network errors, mid-body resets, 5xx/408/429, stalls) are retried with jittered exponential backoff, up to 8 attempts, and wait foronlinewhile the browser reports offline. Subresource integrity is checked after the download, sincefetch({ integrity })exposes no bytes until the body is complete, which would hide a stall.dotnet.native.wasm: after the verified download, the runtime gets aforce-cacheresponse for the same URL. The browser only reuses compiled WebAssembly (its code cache) for a fetched response, not one built from a buffer. Hosts sendingno-storekeep the buffered copy.dotnet.runtime,dotnet.native) are imported inonConfigLoaded, which the runtime awaits, so its laterimport()resolves from the module map. A failed import stays in the module map, so retries use?r=N, andloadBootResourcehands the runtime the URL that worked.blob:URLs don't work, because emscripten resolves paths againstimport.meta.url. A stalledimport()can't be aborted, so it's abandoned after the headers timeout.uno-config.js,dotnet.js, and therequire.jsdependencies, includingAppManifest.js, are retried the same way.DOMContentLoaded: the bootstrapper only calledpreInit()from a listener for it. Whenuno-bootstrap.jswas imported after the document was parsed, the loader was never set up, and the first progress report threwCannot set properties of undefined (setting 'max').UNO_BOOTSTRAP_FETCH_HEADERS_TIMEOUT_MS,_IDLE_TIMEOUT_MSand_MAX_ATTEMPTS. Docs: new "Resilient loading" page.Not covered: the files
index.htmlreferences directly (require.js,uno-bootstrap.js, stylesheets) are loaded by the browser. #1097 makes the stylesheets non-blocking.Validation
New
Uno.Wasm.Tests.ResilientLoading(CI, linux): a server fails the first request of every boot resource, rotating through a reset mid-body, a stall and a 503, and also serveslate.html, which importsuno-bootstrap.jsafterload. The RayTracer must start on both.uno-config.js) fails startup;late.htmlnever starts.On a Uno 7.0 template app, through a test server simulating 4G with injected faults (cold loads, all PRs of this series combined):
Cold load speed without faults is unchanged (10.70 s vs 10.70 s median, n=5). The remaining failures under the harshest profile come from fetches made later by the app itself (Uno's
uno-assets.txtmanifest), which unoplatform/uno needs to make resilient as well.🤖 Generated with Claude Code
https://claude.ai/code/session_01N5azy6DU7ujLte16VPVYQs