Skip to content

fix pwa installability when using noopServiceWorker "Page does not work offline" #5327

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

Merged
merged 1 commit into from
Jan 6, 2021
Merged

fix pwa installability when using noopServiceWorker "Page does not work offline" #5327

merged 1 commit into from
Jan 6, 2021

Conversation

kubenstein
Copy link
Contributor

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Other information:

Hi,
currently Google Chrome prevents installing local pwa due to the error: "Page does not work offline". The reason is service worker has to listen to fetch event. Since in localhost we serve noopServiceWorker we should not cache any requests thus fetch listener should be an empty function.

The reason why i think this change is important is, pwa technologies are quite complex and there are already lots of debugging involved, so being able to quickly see (+) install icon in google chrome will prevent early giving up on pwa by new comers.

Unfortunately I couldnt find docs explaining why fetch listener is needed, the solution is taken from this stackoverflow answer. I did check that empty fetch listener doesnt have any side effects besides installability, as implementing any form of request interception is done via event.respondWith [1] [2]

…orker

currently google chrome prevents installing pwa due to the error: “Page does not work offline”. The reason is service worker has to listen to fetch event. It doesnt have to do anything so the listener can be an empty function, but it has to be declared
@haoqunjiang haoqunjiang merged commit ffc0686 into vuejs:dev Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants