-
Notifications
You must be signed in to change notification settings - Fork 12k
NGSW based Service Worker doesn't work in ng8 with differential builds #15259
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
Hi @elylucas, I downloaded your reproduction and tried it locally and I was not able to replicate the exact issue that you are reporting. I am using Chrome version That being said, I can see a different error which is for the |
…refetched files in ngws-config.json (#15277) In the latest versions of Chrome Version 76.0.3809.100, the `manifest.webmanifest` is being requested when offline and is caused a 504 error. #15259 (comment)
…refetched files in ngws-config.json (#15277) In the latest versions of Chrome Version 76.0.3809.100, the `manifest.webmanifest` is being requested when offline and is caused a 504 error. #15259 (comment)
hi, I have similar issue like @elylucas . However, it randomly happens, sometimes I can reproduce it, sometimes I can't |
Currently facing this issue as well. Happens consistently between builds. Once you receive this error, refreshing the browser then fetches the latest and everything is happy. |
Also having this issue on a new project. |
It seems for me using NPM package |
Hello! This issue is still persist in my environment. I will really appreciate if fix is available. |
Just ran into this also... target change to es5 from es2015 seems to have "fixed" it but a real fix would be nice. Also a simple reload after ngsw has download the new files also allows the app to load, which is very strange and seems like ngsw-worker.js has some interaction with Chrome (if this indeed only happens on Chrome, I haven't tested that). |
service-workers seem to have a problem no finding the relevant resources on es2015 angular/angular-cli#15259 (comment)
## [2.14.4](2.14.3...2.14.4) (2020-07-19) ### Bug Fixes * **conflict-resolution:** ensure conflict resolution is done on raw docs rather than entity instance ([3219f21](3219f21)) * **updates:** prevent problems updating to latest version ([b4603c1](b4603c1)), closes [/github.com/angular/angular-cli/issues/15259#issuecomment-635055255](https://github.com//github.com/angular/angular-cli/issues/15259/issues/issuecomment-635055255) * **webdav:** add way to easily include additional nginx configs for nextcloud forwarding ([298e27a](298e27a))
This issue is now obsolete since differential loading will be removed in the next major version. See: #21467 |
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. |
🐞 Bug report
Command (mark with an
x
)Description
When doing a production build with differential builds (target = es2015 in tsconfig), the service worker does not properly serve up cached esm js files. It throws an error (below in the error section) in the browser console window.
Turning off differential builds (by settings target to es5 in tsconfig) fixes the issue.
🔬 Minimal Reproduction
Create a new app:
ng new ng8-pwa-test
(I added routing and selected CSS)Update the bits to make sure on latest:
ng upgrade @angular/cli @angular/core
Add NGSW:
ng add @angular/pwa
Do a prod build:
ng build --prod
Use a local web server to serve up the dist/ng8-pwa-test (using (https://www.npmjs.com/package/local-web-server)[local-web-server myself]):
ws --spa index.html --static.maxage -1 -p 8080 -z -d dist/ng8-pwa-test
Visit http://localhost:8080, open dev tools and verify the service worker is running on the Application tab. Maybe refresh a few times to make sure everything is nice and primed.
Go offline via the Service Worker tab.
Refresh, and get the error down below in the error section.
Now, go into tsconfig.json and turn off differential builds by setting the target to "es5".
Do another prod build:
ng build --prod
Restart the web server:
ws --spa index.html --static.maxage -1 -p 8080 -z -d dist/ng8-pwa-test
Go back to the browser, unregister the existing service worker, clear out any cache, go back online and see the page again.
Now, go back offline, hit refresh, and see the es5 builds are properly being served from the sw cache.
Heres a link to a project already prepped https://github.com/elylucas/ng8-pwa-test
🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
During testing, I noted that this issue only seems to happen in Chrome (in on v76). I tried in Firefox and Safari and they both seemed to work, but the devtools there aren't as good so not sure if I was going offline properly (i just killed the local server).
Therefore, this could be an issue in Chrome and ESM module loading in service workers.
Im also on Mac OSX Mojava.
The text was updated successfully, but these errors were encountered: