-
Notifications
You must be signed in to change notification settings - Fork 26.2k
bug(service-worker): does not start/install (zone not stabilizing) #20970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@alxhub Hello, do you have any ETA on this bug? I'm also curious to know why using a I have another project which has the a similar problem but does not use any |
Hello @Ploppy3, There is an ongoing investigation into this issue (which affects far more than service worker - the Angular zone never becomes stable in such an app). |
I run into the same problem when I use As a workaround I did that this.ngZone.runOutsideAngular(() => {
interval(ms).subscribe(() => {
this.ngZone.run(() => this.updates.checkForUpdate());
});
}); and everything works fine now, but this is just a workaround. By the way, awesome service worker integration, big thx for that! |
@skydever I implemented this already but with the regular |
I have been fighting this issue for ~3 months as well. My NGSW never registers and it has been almost impossible to debug. The information here is very helpful though. I run FullStory on my site and it is extremely important to keep in place. However, it does send a I'm working on verifying this atm. I also use Firebase Auth and Firebase DB, so those may also do something to keep the page from being 'stable'. |
OK, I just verified that I had to disable both Firebase and Fullstory to get NGSW to register. After all of these months, just seeing it register finally was a great feeling! My app doesn't render on the page, but I have a SW! 😉 Of course, I can't just pull Firebase and Fullstory from my app in order to use NGSW. I also don't think that I want to run all of AngularFire2 and Firebase outside of Angular. Is there a param that I can sent to override this behavior and force registration? |
As a workaround, I was able to modify some of the files in Then I was able to get my app working in addition to NGSW registered. It would be nice to add a |
@Ploppy3 , could you create a reproduce repo? I would like to debug the |
@JiaLiPassion is it what you ask for? https://github.com/Ploppy3/zone-debug-service-worker |
@Ploppy3 , thank you, I think I may have found the reason, I will try to check it further and create a PR in |
@Ploppy3 , I have created a PR, angular/zone.js#999, I used you repo to test, it worked. @Splaktar , could you try the attached |
@JiaLiPassion Did you try with setTimeout? It may be a problem too, I did not test though. |
@Ploppy3 , I will test it, but updateI tested with you repo, |
Ok thank you very much, do you think this will result in any performance gain ? |
@Ploppy3, I believe performance will be the same with current version. |
@JiaLiPassion Ok, thank you for the explanations, much appreciated. |
@Spaier Thanks for your response. It got fixed. Basically the problem was with base-href setting. so, my ngsw-worker.js sits after localhost/site/. And ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production }) takes actual path than relative path. hence made the same relative by just putting ServiceWorkerModule.register('./ngsw-worker.js', { enabled: environment.production }) and also modified manifest.json for relative path like shown below. {
"name": "kognifai-poseidon-home",
"short_name": "kognifai-poseidon-home",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "./",
"start_url": "./",
"icons": [
{
"src": "assets/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "assets/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "assets/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "assets/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "assets/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
Thanks, |
Ran into this issue on a new Angular 6.1.4 app. Service Worker doesn't install when rxjs' Is there any sign of an official workaround/fix for this issue? It seems odd to me that the docs would recommend this approach if it doesn't work. It seems like there should be some kind of note in the docs that warns about this behavior. |
This is sooooo ugly. Just spent two hours to find out that the documentation is recommending the not-working "solution". I'm fine with running things outside angular zone, I don't even care whether this is a workaround or not. But, for the god's sake, I ask for all the people who will come to this issue some day, fix the documentation! Better it recommends nothing than something that is known to be not working since already half a year. |
@smnbbrv You can open an issue regarding the documentation. Also, only the setTimeout or setInterval statements should run outside the zone, the given function should run in the zone and therefore it does not affect your app.
|
With code comes from angular-cli#8779, also works. That's, wrap the
|
…register sw update
Should it be possible to throw a error when the application does not reach a stable state within x seconds after calling I think that would help a lot of users having this problem. |
Once #21842 lands, we could consider changing the default strategy to registering once stable or when a certain amont of time passes (whichever comes first). |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
Service worker does not start/install.
Expected behavior
Service worker should always start/install.
Minimal reproduction of the problem with instructions
ng new test-service-worker --service-worker
setInterval(function() { console.log('test'); }, 1000);
ng build --prod
Environment
The text was updated successfully, but these errors were encountered: