Gatsby: localStorage being disabled bricks GatsbyJS

Created on 4 Dec 2018  路  4Comments  路  Source: gatsbyjs/gatsby

Description

Access to window.localStorage is not a given (some browsers have it, some don't) and the following line completely stops the JS for kicking in.

https://github.com/gatsbyjs/gatsby/blob/9fc25f3d17329ca34d5121ec88b841ca0dba093f/packages/gatsby/cache-dir/ensure-resources.js#L96

Some cases where localStorage might be disabled:

  • Weird/semi-old browsers (not sexy to work with, I know, but sometimes necessary)
  • Recent ones with "cookies and site data" disabled (see https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document)
  • Some browser extension messing with properties

Steps to reproduce

Go to https://www.gatsbyjs.org/ with "Block third party cookies and site data" enabled (see https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document).

Expected result

You should be able to navigate.

Actual result

We can't navigate between the tabs (moreover: the JS is completely bricked).

Environment (not related to my env)

System:
    OS: macOS 10.14.1
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Shell: 2.7.1 - /usr/local/bin/fish
  Binaries:
    Node: 8.12.0 - /var/folders/w3/t46wpt4n12v37k6zn6xz03bm0000gn/T/yarn--1543923041098-0.9736292242640079/node
    Yarn: 1.12.3 - /var/folders/w3/t46wpt4n12v37k6zn6xz03bm0000gn/T/yarn--1543923041098-0.9736292242640079/yarn
    npm: 6.4.1 - /usr/local/Cellar/node@8/8.12.0/bin/npm
  Browsers:
    Chrome: 70.0.3538.110
    Firefox: 63.0.3
    Safari: 12.0.1
  npmPackages:
    gatsby: ^2.0.61 => 2.0.61
    gatsby-image: ^2.0.22 => 2.0.22
    gatsby-plugin-compile-es6-packages: ^1.0.6 => 1.0.6
    gatsby-plugin-favicon: ^3.1.4 => 3.1.4
    gatsby-plugin-lodash: ^3.0.3 => 3.0.3
    gatsby-plugin-react-helmet: ^3.0.4 => 3.0.4
    gatsby-plugin-robots-txt: ^1.0.2 => 1.3.0
    gatsby-plugin-sharp: ^2.0.14 => 2.0.14
    gatsby-plugin-sitemap: ^2.0.3 => 2.0.3
    gatsby-plugin-styled-components: ^3.0.4 => 3.0.4
    gatsby-plugin-web-font-loader: ^1.0.4 => 1.0.4
    gatsby-source-contentful: ^2.0.17 => 2.0.17
    gatsby-source-filesystem: ^2.0.10 => 2.0.10
    gatsby-transformer-csv: ^2.0.5 => 2.0.5
    gatsby-transformer-json: ^2.1.6 => 2.1.6
    gatsby-transformer-remark: ^2.1.15 => 2.1.15
    gatsby-transformer-sharp: ^2.1.9 => 2.1.9
stale? bug

Most helpful comment

@pieh I've got an open PR which fixes this (#10224) - may also fix some other problems with the EnsureResources component

All 4 comments

/cc @davidbailey00
We should somewhat gracefully degrade if localStorage is disabled - probably disable attempts to recover from any network errors there?

@pieh I've got an open PR which fixes this (#10224) - may also fix some other problems with the EnsureResources component

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Fixed in #10432

Was this page helpful?
0 / 5 - 0 ratings

Related issues

totsteps picture totsteps  路  3Comments

rossPatton picture rossPatton  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

andykais picture andykais  路  3Comments

signalwerk picture signalwerk  路  3Comments