Skip to content
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

SessionStorage exception when blocking cookies #34512

Closed
2 tasks done
herecydev opened this issue Jan 17, 2022 · 0 comments · Fixed by #34525
Closed
2 tasks done

SessionStorage exception when blocking cookies #34512

herecydev opened this issue Jan 17, 2022 · 0 comments · Fixed by #34525
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby

Comments

@herecydev
Copy link
Contributor

Preliminary Checks

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

  1. gatsby build
  2. gatsby serve
  3. 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

@herecydev herecydev added the type: bug An issue or pull request relating to a bug in Gatsby label Jan 17, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 17, 2022
@LekoArts LekoArts added good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants