question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Routing error in dev mode: TypeError: Cannot read property 'includes' of undefined

See original GitHub issue

Bug 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.

  1. Launch dev server
  2. Load any URL
  3. 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

Screen Shot 2020-09-05 at 1 02 23 PM

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:closed
  • Created 3 years ago
  • Reactions:41
  • Comments:40 (8 by maintainers)

github_iconTop GitHub Comments

26reactions
michaelbulpittcommented, Oct 29, 2020

I see this issue whilst using mirage.js

@haluvibe If you add

this.passthrough('/_next/static/development/_devPagesManifest.json'); to the top of your routes() function in mirage.js that should solve the problem.

21reactions
deluccacommented, Nov 7, 2020

I see this issue whilst using mirage.js

@haluvibe If you add

this.passthrough('/_next/static/development/_devPagesManifest.json'); to the top of your routes() function in mirage.js that should solve the problem.

Just a quick note, if you’re using a namespace, you should use this solution instead:

      this.passthrough((request) => {
        if (request.url === "/_next/static/development/_devPagesManifest.json") return true;
      });
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found