nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

any parameter you specify in a window.location.reload() call will be ignored and have no effect of any kind

Open spencer1994 opened this issue 1 year ago • 0 comments

scene: in the SPA mode, if the [hash].js of the next page load fail, it will trigger the code window.location.reload(true).

However, in all other browsers, any parameter you specify in a location.reload() call will be ignored and have no effect of any kind.

if load the js always fail, it will reload page and no message are notified to the developer each time.


reason: in the file, line 42

  const onScriptComplete = script.onerror = script.onload = (event) => {
    // Cleanups
    clearTimeout(timeout)
    delete chunksInstalling[chunkId]

    // Avoid mem leaks in IE
    script.onerror = script.onload = null

    // Verify chunk is loaded
    if (chunks[chunkId]) {
      return resolve(chunks[chunkId])
    }

    // Something bad happened
    const errorType = event && (event.type === 'load' ? 'missing' : event.type)
    const realSrc = event && event.target && event.target.src
    error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'
    error.name = 'ChunkLoadError'
    error.type = errorType
    error.request = realSrc
    failedChunks[chunkId] = error
    reject(error)
  }

in the file,line 209

// Handle chunk loading errors
// This may be due to a new deployment or a network problem
if (/^Loading( CSS)? chunk (\d)+ failed\./.test(message)) {
  window.location.reload(true /* skip cache */)
  return // prevent error page blinking for user
}

mdn link image


expect: Can you expose a configuration item to control whether window.location.reload(true) is triggered?

spencer1994 avatar Sep 14 '22 12:09 spencer1994