Routing error in dev mode: TypeError: Cannot read property 'includes' of undefined
See original GitHub issueBug report
Describe the bug
Beginning in Next.js v9.5.3, clicking on any internal link while running in development mode causes an error (shown below) which prevents the navigation from happening. It works fine in v9.5.2.
To Reproduce
I do not have a minimal reproduction example, but it is occurring in our private repo. Rolling back to v9.5.2 fixes the issue.
- Launch dev server
- Load any URL
- Click any internal link
Unhandled Runtime Error
TypeError: Cannot read property 'includes' of undefined
Call Stack
Router._resolveHref
webpack-internal:///./node_modules/next/dist/next-server/lib/router/router.js (911:18)
Router._callee$
webpack-internal:///./node_modules/next/dist/next-server/lib/router/router.js (441:31)
tryCatch
webpack-internal:///./node_modules/regenerator-runtime/runtime.js (63:40)
Generator.invoke [as _invoke]
webpack-internal:///./node_modules/regenerator-runtime/runtime.js (293:22)
Generator.eval [as next]
webpack-internal:///./node_modules/regenerator-runtime/runtime.js (118:21)
asyncGeneratorStep
webpack-internal:///./node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (3:24)
_next
webpack-internal:///./node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (25:9)
Expected behavior
Expect browser to navigate to new href location.
Instead, it displays the error above and does not redirect.
Screenshots
System information
- OS: MacOS 10.15.6
- Browser: Brave Version 1.12.114 Chromium: 84.0.4147.135 (Official Build) (64-bit)
- Version of Next.js: 9.5.3
- Version of Node.js: 14.9.0
Additional context
We have a custom server, custom next.config.js
and custom webpack configuration, but all seems to work fine in v9.5.2 and below. Also, this issue does not occur in production mode - only development mode.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:41
- Comments:40 (8 by maintainers)
Top Results From Across the Web
Cannot read property 'includes' of Undefined in JavaScript
The "Cannot read property 'includes' of undefined" error occurs when calling the includes() method on an undefined value. To solve the error, make...
Read more >TypeError: Cannot read property 'includes' of undefined ...
I'm currently creating a --Filter By-- dropdown in my code using selector for my JSON data from the API. But I keep getting...
Read more >cannot read properties of undefined (reading 'includes'
I get TypeError: Cannot read properties of undefined (reading 'includes'), Line of, "const followed, setFollowed " That's the real issue showing?
Read more >تويتر \ Josh Goldberg fosstodon.org/@JoshuaKGoldberg على ...
Routing error in dev mode : TypeError: Cannot read property 'includes' of undefined (take two) ·... Verify canary release I verified that the...
Read more >TypeError: Cannot read property 'includes' of undefined
AR: Javascript exception TypeError: Cannot read property 'includes' of undefined. c.$inject = ["FeatureResource"]; var u = function() { var e = this; this....
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
@haluvibe If you add
this.passthrough('/_next/static/development/_devPagesManifest.json');
to the top of yourroutes()
function inmirage.js
that should solve the problem.Just a quick note, if you’re using a namespace, you should use this solution instead: