Error with Router and prefetching
See original GitHub issueWhat version of Next.js are you using?
12.0.2
What version of Node.js are you using?
14.18.1
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Self deployment
Describe the Bug
Whenever I’m trying to navigate to a page which uses <Link>
(which prefetches by default), router.ts
file prints an error in the console
This error occurs in the _preflightRequest
function in router.ts
On further investigation, I found that, this.pageLoader.getMiddlewareList();
returns a Set (of size 0, since I have no middlewares). And it then tries to call .some
on the Set.
Expected Behavior
The navigation should happen normally
To Reproduce
Upgrade any NextJS project from v11 to v12, and this issue occurs.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
router.prefetch is not a function , Unable to check submit ...
Whenever I need to use "next/router" I always call useRouter like this and assign it to a variable: import { useRouter } from...
Read more >Route prefetching in Next.js - web.dev
In this post you'll learn how routing in Next.js works, how it's optimized for speed, and how to customize it to best fit...
Read more >Prefetching - Redux Toolkit
Prefetching. The goal of prefetching is to make data fetch before the user navigates to a page or attempts to load some known...
Read more >Pre-fetching lazy loaded modules produces an error while ...
I noticed an error which occurred as a result of it. Whenever i tried navigating to a different route before the notify info...
Read more >next/link | Next.js
Before moving forward, we recommend you to read Routing Introduction first. ... When prefetch is set to false , prefetching will still occur...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here, it only occurs in a build deployed to production environment. Running locally, even with a production build, it works fine 😕
Any update on this?