Fix service worker installation failure on Firefox #7755
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.
Summary
This PR fixes a Firefox-specific issue where the service worker fails to install or register. Fixes #7738
Firefox aborts installation if any promise inside
event.waitUntil()rejects.The previous implementation used
cache.addAll(), which can reject when a single precache request fails (e.g.,/manifest.json,/app-shell/index.html, or a Workbox manifest entry).As a result, the entire service worker installation failed on Firefox, even though it worked on Chrome.
This PR replaces
cache.addAll()with defensive per-request caching so that failed precache requests no longer break the install event.What kind of change does this PR introduce?
fix— Prevents service worker installation from failing on Firefox by using safe, per-request precaching.Did you add tests for your changes?
No.
Service worker behavior differs between browsers and is not currently covered by automated tests in this repository.
This fix is isolated to the SW script and does not affect build output.
Does this PR introduce a breaking change?
No.
Chrome and other browsers behave exactly the same as before.
Only Firefox benefits from the more resilient install logic.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
No documentation changes are required.
The service worker behavior is internal and this update does not modify public APIs or user-facing features.