fix(vue-app): don't throw if we can't read sessionStorage (#27662)

This commit is contained in:
Daniel Roe 2024-06-17 12:34:08 +01:00 committed by GitHub
parent 7cec79c437
commit a8a74a91a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -157,12 +157,15 @@ export function resolveRouteComponents (route, fn) {
window.sessionStorage window.sessionStorage
) { ) {
const timeNow = Date.now() const timeNow = Date.now()
const previousReloadTime = parseInt(window.sessionStorage.getItem('nuxt-reload')) try {
const previousReloadTime = parseInt(window.sessionStorage.getItem('nuxt-reload'))
// check for previous reload time not to reload infinitely // check for previous reload time not to reload infinitely
if (!previousReloadTime || previousReloadTime + 60000 < timeNow) { if (!previousReloadTime || previousReloadTime + 60000 < timeNow) {
window.sessionStorage.setItem('nuxt-reload', timeNow) window.sessionStorage.setItem('nuxt-reload', timeNow)
window.location.reload(true /* skip cache */) window.location.reload(true /* skip cache */)
}
} catch {
// don't throw an error if we have issues reading sessionStorage
} }
} }