Skip to content

[Wasm] Recover invalid cached boot resources - #135925

Open
vendasankarsf3945 wants to merge 2 commits into
dotnet:mainfrom
vendasankarsf3945:fix/69488-blazor-wasm-cache-recovery
Open

vendasankarsf3945 wants to merge 2 commits into
dotnet:mainfrom
vendasankarsf3945:fix/69488-blazor-wasm-cache-recovery

Conversation

@vendasankarsf3945

@vendasankarsf3945 vendasankarsf3945 commented Oct 16, 2026 •

Copy link
Copy Markdown

[Wasm] Recover invalid cached boot resources

Summary

Fingerprint-named WebAssembly boot resources are loaded with cache: "force-cache". If the browser stores an unusable response for one of these resources, such as an empty response, non-success response, or a response rejected by integrity validation, subsequent application loads can continue reusing the same cached entry. The application then cannot start until the user manually clears the site's browser data.

Changes

This change adds cache recovery to the Mono and shared/native WebAssembly asset loaders.

For resources using force-cache, the loader now:

  1. Performs the existing fetch without changing its request options.
  2. Returns successful, non-empty responses unchanged.
  3. If the fetch throws, returns a non-success response, or returns an explicitly zero-length response, retries the resource once with cache: "reload".
  4. Propagates a failure from the recovery request without attempting another reload.

The recovery request preserves the existing URL, credentials, integrity metadata, content-type handling, and configured fetch abstraction. Resources that do not use force-cache retain their existing behavior.

The asset's cache mode is also changed to reload after an unusable cached response is detected, preventing the existing higher-level retry path from returning to the same invalid cache entry.

Testing

The browser test host can inject a bounded number of empty, cacheable responses for the client assembly. The added Chromium tests verify that:

  • A fingerprinted application recovers from an empty cached assembly response and starts successfully.
  • A failed recovery stops after one reload.
  • A non-force-cache failure is not retried by this recovery path.
  • The existing healthy-cache behavior remains unchanged.

Validated with the Wasm.Build.Tests real-browser Blazor test infrastructure using Chromium.

Fixes dotnet/aspnetcore#69488

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 16, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@jkotas

jkotas commented Oct 16, 2026

Copy link
Copy Markdown
Member

Fixes #69488

Is this the correct issue link?

@jkotas jkotas added the arch-wasm WebAssembly architecture label Oct 16, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@vendasankarsf3945
vendasankarsf3945 marked this pull request as ready for review October 19, 2026 08:51
@pavelsavara

pavelsavara commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

The underlying problem of storing stale 404 or empty file via force-cache sucks.
I think we get TypeError: Failed to fetch in both cases, because of integrity, right ?
That should not be in the noRetryStatusCodes and so, we could set cache: "reload" for subsequent re-try attempts.

Does cache: "reload" keep item cached after 404 or integrity failure ?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[blazor-wasm] A cached empty or error response for a boot resource is reused forever (force-cache); the app never boots again, even after a hard reload

4 participants