Description
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
Through chrome (probably other browsers as well), users can disable cookies which will cause sessionStorage/localStorage to also throw an exception when accessed. Currently in Gatsby there are places where this is left unchecked, the offending code is here: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/production-app.js#L187-L200
This is actually catered for in the react-router-scroll package, which checks for an exception: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-react-router-scroll/src/session-storage.ts#L9
Potentially this could be extracted and reused as an all purpose function.
Reproduction Link
https://github.com/gatsbyjs/gatsby
Steps to Reproduce
gatsby build
gatsby serve
- In chrome, security & privacy => disable cookies
Expected Result
No exceptions are raised, using sessionStorage should be an enhancement not a given.
Actual Result
Security Exception is raised
Environment
System:
OS: Windows 10 10.0.19042
CPU: (16) x64 AMD Ryzen 9 5950X 16-Core Processor
Binaries:
Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 3.1.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.62)
npmPackages:
gatsby: ^4.5.2 => 4.5.2
gatsby-cypress: ^2.5.0 => 2.5.0
gatsby-plugin-google-tagmanager: ^4.5.0 => 4.5.0
gatsby-plugin-image: ^2.5.1 => 2.5.1
gatsby-plugin-newrelic: ^2.1.1 => 2.1.1
gatsby-plugin-react-helmet: ^5.5.0 => 5.5.0
gatsby-plugin-remove-generator: ^1.2.0 => 1.2.0
gatsby-plugin-sharp: ^4.5.1 => 4.5.1
gatsby-plugin-sitemap: ^5.5.0 => 5.5.0
gatsby-plugin-styled-components: ^5.5.0 => 5.5.0
gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.26 => 1.1.26
gatsby-source-filesystem: ^4.5.1 => 4.5.1
gatsby-transformer-remark: ^5.5.1 => 5.5.1
gatsby-transformer-sharp: ^4.5.0 => 4.5.0
npmGlobalPackages:
gatsby-cli: 4.5.2
Config Flags
No response