Skip to content

Service Worker does not work for offline applications #22976

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

Closed
matthew-a-thomas opened this issue Mar 25, 2018 · 2 comments
Closed

Service Worker does not work for offline applications #22976

matthew-a-thomas opened this issue Mar 25, 2018 · 2 comments
Milestone

Comments

@matthew-a-thomas
Copy link

matthew-a-thomas commented Mar 25, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Since Angular's service worker self-destructs "when the service worker's request for ngsw.json returns a 404", it always eventually self-destructs in all offline scenarios.

Taking the app offline and refreshing the page works as expected the first time: the app still runs because the service worker is serving a cached version. But refreshing the page again after it has failed to find ngsw.json results in a blank screen.

Expected behavior

Angular's service worker should continue serving a cached version of the application in the face of multiple page refreshes in an offline scenario.

Perhaps the self-destruct feature could be preserved by only self-destructing when ngsw.json returns 4xx status code and index.html returns 2xx status code.

Minimal reproduction of the problem with instructions

STEPS TO REPRODUCE:

  1. Follow these steps: https://angular.io/guide/service-worker-getting-started
  2. Serve your application and confirm that the service worker is working.
  3. Take your application offline (or kill your web server).
  4. Refresh the page once.
  5. Wait for the service worker to fail to get ngsw.json.
  6. Refresh the page again.
  7. Observe the blank page.

What is the motivation / use case for changing the behavior?

Building Angular applications for offline use using Angular's Service Workers.

Environment


Angular version: 5.2.9


Browser:
- [x] Chrome (desktop) version 64.0.3282.186
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [x] Edge version 41.16299.248.0
 
For Tooling issues:
- Node version: v8.10.0  
- Platform: Windows 

Others:

@ngbot ngbot bot added this to the needsTriage milestone Mar 25, 2018
@matthew-a-thomas matthew-a-thomas changed the title SwUpdate does not work for offline applications SwUpdate does not work for offline applications Mar 25, 2018
@matthew-a-thomas matthew-a-thomas changed the title SwUpdate does not work for offline applications Service Worker does not work for offline applications Mar 25, 2018
@gkalpak
Copy link
Member

gkalpak commented Mar 25, 2018

Essentially duplicate of #21636. Will be fixed by #22883.

@gkalpak gkalpak closed this as completed Mar 25, 2018
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants