runtime: `dotnet.js` cache busting (fingerprinting), Symptom: Cannot read properties of undefined (reading 'out')
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When upgrading from 8.0.4 to 8.0.5, the dotnet.js changed.
In opposite to dotnet.native.{fingerprint}.js and dotnet.runtime.{fingerprint}.js, the dotnet.js is not fingerprinted and thus cached. The usual Clear site data in F12-DevTools do not help as the file is cached by the browser and still taken from “(disk cache)”.
The 8.0.4 dotnet.js is not compatible with 8.0.5 dotnet.native.{...}.js or dotnet.runtime.{...}.js and the symptom is:
logging.ts:32 MONO_WASM: TypeError: Cannot read properties of undefined (reading 'out')
at $l (https://localhost:44303/_framework/dotnet.runtime.8.0.5.gongq8hbow.js:3:198913)
at ze (https://localhost:44303/_framework/dotnet.js:3:30895)
at https://localhost:44303/_framework/dotnet.js:3:30131
at async Object.create (https://localhost:44303/_framework/dotnet.js:3:34510)
at async https://localhost:44303/_framework/blazor.web.js:1:154483
at async https://localhost:44303/_framework/blazor.web.js:1:164313
startup.ts:43 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'out')
at $l (startup.ts:43:17)
at ze (run.ts:461:11)
at run.ts:505:11
at async Object.create (run.ts:361:72)
at async blazor.web.js:1:154483
at async blazor.web.js:1:164313
(No module parameter set when calling configureRuntimeStartup() from initializeModules().)
Expected Behavior
dotnet.js to be correctly fingerprinted (As it already used to be before splitting to several files?).
Steps To Reproduce
VS 2022 17.9.6 - Create new BWA - WebAssembly project + run locally in browser. Update VS to 17.9.7 (brings dotnet 8.0.5). Run the same project again.
Exceptions (if any)
No response
.NET Version
8.0.5 (9.0.0-preview3 still does not resolve this issue)
Anything else?
WORKAROUND: Ctrl+F5 in browser to force reloading the file.
(It seems this is already in progress, as there are some options in tests which enable checking the fingerprinting on dotnet.js.)
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 11
- Comments: 52 (25 by maintainers)
We can use
loadBootResourceto modify a URL resolution for dotnet.jsIn the sample I’m adding also a query string for blazor.web.js, which shouldn’t be required for this particular issue. Standalone app can be modified similarly. More details in https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-8.0#load-client-side-boot-resources
There is a guidance about hosting and upgrading blazor apps https://github.com/dotnet/aspnetcore/issues/52022 (the title mentions “major” upgrade, but in reality the situation can happen even with servicing release).
The situation will be better for hosted mode in .NET 9 thanks to https://github.com/dotnet/sdk/pull/39405 and https://github.com/dotnet/sdk/pull/39636.
For standalone mode ideally we should be fingerprinting everything (blazor.js, dotnet.js, all dlls/wasms, but also scripts and styles from nuget packages). But that requires rewriting code that references those files. Unlike for webpack and similar we don’t have tooling to do it safely. We should review again if we can it do for the most typical scenarios
This is unfortunately just about moving the problem to a different file
The issue persists when publishing to a folder from Visual Studio v17.11.2 (
dotnet --version8.0.400): filesdotnet.jsanddotnet.js.gzget updated, butdotnet.js.brgets stuck on the old version. Cleaning upbinandobjdirectories before publishing fixes the problem.@steamonimo Same issue here but it was resolved after seeing https://github.com/dotnet/aspnetcore/issues/55751#issuecomment-2116002683 that says to delete obj and bin folders before deploying and clearing cache on browser.
@steamonimo Sorry for late reply. From the build log is visible that it skipped copying
dotnet.jsas the build has decided it’s new enough. Do you have by any change still the build output on disk? Can you upload the_framework/dotnet.jsas well?@maraf Here are the binlog files. Please let me know if you need more!
I am having the exact same problem. Also deploying to Azure Static Web Apps. Runs fine locally. I also tried the above cache busting work around, but didn’t fix my problem either.
Hey.
Also getting the issue here. We are running a .net 8 Blazor WASM standalone app.
Have tried the above workaround regarding the
loadBootResource, but doesn’t work for us, and we still get the same errors. (I did make the relevant changes from the code posted, to wasm standalone, whiere were the following:)We are deploying using Azure DevOps, and calling the task
AzureStaticWebApp@0. Is there a way for us to work around this issue currently that anyone is aware of?From my testing it has always served HTML with
cache-control: no-cache, no-storeOk, that would explain it.
Re. index.html / App.Razor, I’ve never had a problem with the browser caching the Blazor WebAssembly-served HTML. E.g. all changes I make here are immediately picked up, and I’ve never had to worry about having to hit ctrl+F5 or anything like that.
@maraf is there a chance that blazor/dotnet.js get out of “sync”? if not, we could on the Blazor side, stamp the version for the import as part of the build process, and we could then also stamp the 8.0.x on the relevant dotnet.js file as part of the build to make sure everything lines up.