router.push
hangs and does not trigger hard reload if router.prefetch
fails to load a file more than once
#28038
Labels
bug
Issue was opened via the bug report template.
What version of Next.js are you using?
11.1.0
What version of Node.js are you using?
14.x
What browser are you using?
Chome - Version 92.0.4515.131 (Official Build) (x86_64)
What operating system are you using?
macOS 10.15.7
How are you deploying your application?
Vercel
Describe the Bug
If
router.prefetch
fails to load a file twice subsequentrouter.push
calls for the route do not attempt to load the file and do not resolve. NorouteChangeCompleted
orrouteChangeError
events fire, and a hard reload is not triggered.Expected Behavior
The
router.push
call will attempt to load the missing file. If the file still cannot be loaded arouteChangeError
event will fire, therouter.push
call will resolve with a value offalse
, and a hard reload will be used to load the target route.To Reproduce
Example repo: https://github.com/timswalling/next-prefetch-bug
next-prefetch-bug.vercel.app/_next/static/chunks/pages/page-2-*.js
router.prefetch
button and verify that thepage-2
chunk fails to loadrouter.prefetch
button and verify that thepage-2
chunk fails to load againrouter.push
and verify that no further attempt is made to load thepage-2
chunk, and that therouter.push
call does not resolveThe text was updated successfully, but these errors were encountered: