Skip to content

Commit

Permalink
fix(gatsby): handle session storage not being available (#34525) (#34539
Browse files Browse the repository at this point in the history
)

Co-authored-by: Dan Kirkham <herecy@live.co.uk>
  • Loading branch information
ViCo0TeCH and herecydev committed Jan 19, 2022
1 parent c493ee7 commit e69270b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/gatsby/cache-dir/production-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,18 @@ apiRunnerAsync(`onClientEntry`).then(() => {
)
}

// It's possible that sessionStorage can throw an exception if access is not granted, see https://github.com/gatsbyjs/gatsby/issues/34512
const getSessionStorage = () => {
try {
return sessionStorage
} catch {
return null
}
}

publicLoader.loadPage(browserLoc.pathname + browserLoc.search).then(page => {
const sessionStorage = getSessionStorage()

if (
page?.page?.webpackCompilationHash &&
page.page.webpackCompilationHash !== window.___webpackCompilationHash
Expand Down

0 comments on commit e69270b

Please sign in to comment.