Skip to content

Commit 06def5c

Browse files
Workaround CacheStorage API bug
1 parent 6a85855 commit 06def5c

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.webassembly.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Platform/WebAssemblyResourceLoader.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ export class WebAssemblyResourceLoader {
3636
loadResource(name: string, url: string, contentHash: string): LoadingResource {
3737
// Setting 'cacheBootResources' to false bypasses the entire cache flow, including integrity checking.
3838
// This gives developers an easy opt-out if they don't like anything about the default cache mechanism.
39-
const response = this.bootConfig.cacheBootResources
39+
40+
// There's also a Chromium bug we need to work around here: the CacheStorage APIs say that when
41+
// caches.open(name) returns a promise that succeeds, the value is meant to be a Cache instance.
42+
// However, if the browser was launched with a --user-data-dir param that's "too long" in some sense,
43+
// then even through the promise resolves as success, the value given is `undefined`.
44+
// See https://stackoverflow.com/a/46626574. We're reporting this to Chromium and others, but in
45+
// the meantime, if this.cache isn't set, just proceed without caching.
46+
const useCache = this.bootConfig.cacheBootResources && this.cache;
47+
48+
const response = useCache
4049
? this.loadResourceWithCaching(name, url, contentHash)
4150
: fetch(url, { cache: networkFetchCacheMode });
4251
return { name, url, response };

0 commit comments

Comments
 (0)