Skip to content

Commit

Permalink
use sessionStorage instead of location.hash to check if page has been…
Browse files Browse the repository at this point in the history
… reloaded
  • Loading branch information
rinu committed Mar 24, 2021
1 parent 9ecf77d commit 3899222
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/vue-app/template/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,20 @@ export function resolveRouteComponents (route, fn) {
} catch (error) {
// Handle webpack chunk loading errors
// This may be due to a new deployment or a network problem
if (error && error.name === 'ChunkLoadError' && window.location.hash !== '#retry') {
// mark the page not to reload infinitely
window.location.hash = '#retry'
window.location.reload(true /* skip cache */)
if (
error &&
error.name === 'ChunkLoadError' &&
typeof window !== 'undefined' &&
window.sessionStorage
) {
const timeNow = (new Date()).getTime()
const previousReloadTime = window.sessionStorage.getItem('nuxt-reload')

// check for previous reload time not to reload infinitely
if (!previousReloadTime || previousReloadTime + 60000 < timeNow) {
window.sessionStorage.setItem('nuxt-reload', timeNow)
window.location.reload(true /* skip cache */)
}
}

throw error
Expand Down

0 comments on commit 3899222

Please sign in to comment.