Fix service worker installation failure on Firefox#7755
Fix service worker installation failure on Firefox#7755pranjalisr wants to merge 20 commits intowebpack:mainfrom
Conversation
|
@pranjalisr is attempting to deploy a commit to the OpenJS Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
@alexander-akait Just following up to kindly request a review of this PR when you have availability. |
|
@evenstensberg Can you look at this and test, I think we can merge it |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Tested in Firefox using production build (yarn build + yarn serve-dist). Service worker installs successfully and no longer aborts on install.
@evenstensberg Can you please check this? If this sounds Ok then I will push the code changes. |
ovflowd
left a comment
There was a problem hiding this comment.
Appreciate the contribution. Code is not ideal, made a few suggestions :)
src/sw.js
Outdated
| (async () => { | ||
| const cache = await caches.open(cacheName); | ||
|
|
||
| // Fail install only if "required" assets fail |
There was a problem hiding this comment.
this line isn't really needed, and you don't really need a hardcoded EXCLUDED_PRECACHE_URLS. Simply do
await Promise.allSettled(
allManifestURLs.map((url) => cache.add(url)),
);This will already ignore failures gracefully.
There was a problem hiding this comment.
Made code changes. Checked locally, running fine. Please review


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.