gatsby: [v2] [gatsby-plugin-offline] Service Workers throw errors when offline

It seems that service workers are broken on v2. They are successfully installed, but return errors when the user is offline:

Cannot read property ‘pageContext’ of undefined

screen shot 2018-06-28 at 10 42 56 am

This also leads to this Lighthouse warning:

Service worker does not successfully serve the manifest’s start_url.

Could potentially be related to the pageContext rename?

Steps to reproduce

Example repo: https://github.com/fabe/test-gatsby-v2-offline
Production build: https://peaceful-wozniak-ecfc89.netlify.com

Reload the site while offline (after installing the service worker).

Environment

  System:
    OS: macOS High Sierra 10.13.5
    CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 8.11.3 - /usr/local/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 5.6.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 67.0.3396.99
    Safari: 11.1.1
  npmPackages:
    gatsby: next => 2.0.0-beta.12
    gatsby-plugin-offline: ^2.0.0-beta.2 => 2.0.0-beta.2
  npmGlobalPackages:
    gatsby-cli: 1.1.58

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 29 (25 by maintainers)

Most upvoted comments

hey @fabe thanks for submitting this! I’m actually working on this problem right now!

I’m making progress on a better fix, although it’s taking me a long time due to various interdependent bugs which I’m also trying to fix. I’ll post an update later when I’ve made more progress