Skip to content

Commit

Permalink
fix(gatsby): handle session storage not being available (#34525)
Browse files Browse the repository at this point in the history
  • Loading branch information
herecydev committed Jan 18, 2022
1 parent d2ba1f9 commit 77e4bb0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/gatsby/cache-dir/production-app.js
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 77e4bb0

Please sign in to comment.