You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InjectionToken SwRegistrationOptions is ignored when using standalone bootstrapApplication function. #57824
Which @angular/* package(s) are the source of the bug?
service-worker
Is this a regression?
Yes
Description
Hi, I've made a little repo to illustrate the issue.
When using the old NgModule based syntax to init your app with a service worker, then your provided SwRegistrationOptions is found and respected.
Runing the app gives you a console log.
When using standalone app syntax, via bootstrapApplication then your provided SwRegistrationOptions is not not found nor respected. Runing the app does not give you a console log.
Likely it was overlooked in the PR where the provideServiceWorker function was added. Or perhaps I'm just misunderstanding how it's supposed to work now.
Please provide a link to a minimal reproduction of the bug
Aha, I looked at the unit tests for the feature and noticed that there's coverage for the SwRegistrationOptions override case, and the tests are obviously green :)
It turns out that the order is important here. One must register the custom options AFTER calling provideServiceWorker, as that function will overwrite your provider with the (non existing) options passed in as second argument.
Activity
antur84 commentedon Sep 16, 2024
Aha, I looked at the unit tests for the feature and noticed that there's coverage for the
SwRegistrationOptionsoverride case, and the tests are obviously green :)It turns out that the order is important here. One must register the custom options AFTER calling
provideServiceWorker, as that function will overwrite your provider with the (non existing) options passed in as second argument.The following works ✅
While this does not work
JeanMeche commentedon Aug 29, 2025
With #63364 we've announced that the service-worker package in now in maintenance mode and will not receive feature PRs and feature requests.
The message is also visible here: https://angular.dev/ecosystem/service-workers
angular-automatic-lock-bot commentedon Sep 29, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.