gatsby 4.5.3 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,11 +133,22 @@ const reloadStorageKey = `gatsby-reload-compilation-hash-match`;
133
133
  (0, _reachRouter.navigate)(__BASE_PATH__ + pagePath + (!pagePath.includes(`?`) ? browserLoc.search : ``) + browserLoc.hash, {
134
134
  replace: true
135
135
  });
136
- }
136
+ } // It's possible that sessionStorage can throw an exception if access is not granted, see https://github.com/gatsbyjs/gatsby/issues/34512
137
+
138
+
139
+ const getSessionStorage = () => {
140
+ try {
141
+ return sessionStorage;
142
+ } catch {
143
+ return null;
144
+ }
145
+ };
137
146
 
138
147
  _loader.publicLoader.loadPage(browserLoc.pathname + browserLoc.search).then(page => {
139
148
  var _page$page;
140
149
 
150
+ const sessionStorage = getSessionStorage();
151
+
141
152
  if (page !== null && page !== void 0 && (_page$page = page.page) !== null && _page$page !== void 0 && _page$page.webpackCompilationHash && page.page.webpackCompilationHash !== window.___webpackCompilationHash) {
142
153
  // Purge plugin-offline cache
143
154
  if (`serviceWorker` in navigator && navigator.serviceWorker.controller !== null && navigator.serviceWorker.controller.state === `activated`) {
@@ -162,7 +162,18 @@ apiRunnerAsync(`onClientEntry`).then(() => {
162
162
  )
163
163
  }
164
164
 
165
+ // It's possible that sessionStorage can throw an exception if access is not granted, see https://github.com/gatsbyjs/gatsby/issues/34512
166
+ const getSessionStorage = () => {
167
+ try {
168
+ return sessionStorage
169
+ } catch {
170
+ return null
171
+ }
172
+ }
173
+
165
174
  publicLoader.loadPage(browserLoc.pathname + browserLoc.search).then(page => {
175
+ const sessionStorage = getSessionStorage()
176
+
166
177
  if (
167
178
  page?.page?.webpackCompilationHash &&
168
179
  page.page.webpackCompilationHash !== window.___webpackCompilationHash
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby",
3
3
  "description": "Blazing fast modern site generator for React",
4
- "version": "4.5.3",
4
+ "version": "4.5.4",
5
5
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
6
6
  "bin": {
7
7
  "gatsby": "./cli.js"
@@ -258,5 +258,5 @@
258
258
  "yargs": {
259
259
  "boolean-negation": false
260
260
  },
261
- "gitHead": "c493ee721c16b5101134bcd98fdf4f6f0e40cede"
261
+ "gitHead": "80b3915e1373ef8c277e50fdfd6178b9930c830c"
262
262
  }