Unverified Commit 535bab16 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Fix double-reload / redirect when changing pages (#4388)

When changing a page `/_app` can be seen as “updated”,  but the router shouldn’t reload it, because there is an ongoing/going to be ongoing update.
parent 3db3f4b4
...@@ -179,14 +179,26 @@ export default class HotReloader { ...@@ -179,14 +179,26 @@ export default class HotReloader {
this.send('reload', route) this.send('reload', route)
} }
let changedPageRoutes = []
for (const [n, hash] of chunkHashes) { for (const [n, hash] of chunkHashes) {
if (!this.prevChunkHashes.has(n)) continue if (!this.prevChunkHashes.has(n)) continue
if (this.prevChunkHashes.get(n) === hash) continue if (this.prevChunkHashes.get(n) === hash) continue
const route = toRoute(relative(rootDir, n)) const route = toRoute(relative(rootDir, n))
changedPageRoutes.push(route)
}
// This means `/_app` is most likely included in the list.
// We filter it out because `/_app` will be re-rendered with the page
if (changedPageRoutes.length > 1) {
changedPageRoutes = changedPageRoutes.filter((route) => route !== '/_app')
}
for (const changedPageRoute of changedPageRoutes) {
// notify change to recover from runtime errors // notify change to recover from runtime errors
this.send('change', route) this.send('change', changedPageRoute)
} }
} }
...@@ -277,6 +289,10 @@ export default class HotReloader { ...@@ -277,6 +289,10 @@ export default class HotReloader {
} }
async ensurePage (page) { async ensurePage (page) {
// Make sure we don't re-build or dispose prebuilt pages
if (page === '/_error' || page === '/_document' || page === '/_app') {
return
}
await this.onDemandEntries.ensurePage(page) await this.onDemandEntries.ensurePage(page)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment