-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(gatsby-plugin-offline): gracefully degrade if appshell isn't precached #10329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's get this merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern is that someone could visit a page while the offline shell is downloading, but then because they loaded another page first, we've prevented the shell from being served even if it was almost downloaded.
For this reason I think it would be better to not have a failedToGrabAppShell
variable so that we allow it to retry later - in fact, it would be best to replace return fetch(event.request)
with a fetch to the offline shell (it will be auto-cached upon successful load).
So I introduced a bit of Changes I've made: Huge thanks to @davidbailey00 for help on this one! |
* master: (870 commits) fix(graphql-skip-limit): declare `graphql` peer dependency (gatsbyjs#10305) fix(gatsby-plugin-offline): gracefully degrade if appshell isn't precached (gatsbyjs#10329) Service workers note (gatsbyjs#10276) fix(docs): link fixes, podcast addition (gatsbyjs#10332) feat(docs): Create clearer pathways in docs (gatsbyjs#9898) feat(www): Rename community section to creators (gatsbyjs#10312) docs(graphql-reference): clarify filtering using comma/and operator (gatsbyjs#10321) chore(release): Publish feat(gatsby-plugin-sass): Support Dart SASS (gatsbyjs#10159) fix(gatsby-source-drupal): use basic auth credentials to fetch remote files as well. (gatsbyjs#10302) fix(gatsby-source-filesystem): allow empty password for basic auth in createRemoteFileNode (gatsbyjs#10280) docs(gatsby-remark-prismjs): Use Gatsby V2 project structure (gatsbyjs#10059) chore: update link for react-gatsby-firebase-authentication (gatsbyjs#10314) fix(www): Awesome Gatsby sidebar link (gatsbyjs#10313) Add thijs koerselman to creators list (gatsbyjs#10303) chore(release): Publish fix(gatsby-plugin-emotion): allow for React.Fragment shorthand syntax (gatsbyjs#10291) feat(www): Update starter cards (gatsbyjs#10258) Update index.md (gatsbyjs#10307) Update index.md (gatsbyjs#10306) ...
* master: (1421 commits) feat(gatsby-image): add onStartLoad prop (#6702) fix(docs): add Ecosystem to docs sidebar, consistency with tutorial sidebar (#10350) fix(www): Starters.yaml housekeeping (#10354) docs: add ttag starter (#10352) docs: document branching (#9983) plugin checker initial commit (#7062) docs: new starter features is required (#10353) docs: migrated line highlighting to highlight-line, highlight-start, highlight-end (#10202) Add Birra Napoli to site showcase (#10344) Add BetterDocs to site showcase (#10349) chore(release): Publish Add option to keep metadata in files processed by `gatsby-plugin-sharp` (#10210) fix(gatsby): [loki] sync db autosaves (#10212) Add Ad Hoc Homework to sites.yml (#10346) fix(graphql-skip-limit): declare `graphql` peer dependency (#10305) fix(gatsby-plugin-offline): gracefully degrade if appshell isn't precached (#10329) Service workers note (#10276) fix(docs): link fixes, podcast addition (#10332) feat(docs): Create clearer pathways in docs (#9898) feat(www): Rename community section to creators (#10312) ...
…ached (gatsbyjs#10329) If app shell is not in precache (for whatever reason) - try to fetch it. If we fetch successfully - put it in precache for any future requests so we can use happy path again. If we can't fetch app shell - fallback to fetching actual html content of the page.
fixes gatsbyjs#10151 Issue in `gatsby-plugin-offline` was fixed in gatsbyjs#10329, but gatsbyjs.org didn't upgrade.
It's not clear what cause app shell to not be succesfully precached and this is hot fix to fix serving blank page with following error in console:
The FetchEvent for "<url>" resulted in a network error response: an object that was not a Response was passed to respondWith().
Ideally we would try to push that offline appshell to precache in this case. Fix in this PR will only work when people are online
/cc @davidbailey00