Skip to content

Workbox precaching network fallback cannot handle integrity #3096

@zlk89

Description

@zlk89

Library Affected:
workbox-precaching

Browser & Platform:

Google Chrome v103.0.5060.114 for Mac

Issue or Feature Request Description:

In service worker:

const manifest = self.__WB_MANIFEST;
precacheAndRoute(manifest, {});
cleanupOutdatedCaches();

Way to reproduce:

  1. Set SRI integrity in manifest
  2. load the website and wait for SW to precache all manifest entries and install
  3. Manually delete the cache storage in Application tab or clear storage in Chrome setting
  4. reload the website, it will fallback the network request here, because the cache item has been cleared:
    if (this._fallbackToNetwork) {
  5. You should see the SRI error, because the fetch didn't use cors mode. (see TypeError on Request.integrity with no-cors mode is a foot gun whatwg/fetch#583 for context)

Potential fix: when integrity is used, it should use cors mode to fetch the resource

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions