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.

Navigating between server component + client component page throws error - Cannot read properties of undefined (reading '')

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 16.15.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 13.0.1-canary.0
  eslint-config-next: 13.0.0
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When I visit a server component page and then visit a client component page, I will no longer be able to access the server component page I previously accessed. This is the same case when you have client components inside server component pages.

Flow:

  1. Run the Next.js app in development mode.
  2. Visit root server component page, i.e. /
  3. Visit client component page, i.e. /client-page
  4. Visit root server component page, i.e. /

Result: A white page and an error in my terminal/console.

event - compiled client and server successfully in 434 ms (198 modules)
wait  - compiling /page (client and server)...
event - compiled client and server successfully in 206 ms (333 modules)
wait  - compiling /client-page/page (client and server)...
event - compiled client and server successfully in 124 ms (345 modules)
TypeError: Cannot read properties of undefined (reading '')
    at resolveModuleMetaData (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:195:82)
    at serializeModuleReference (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1298:50)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1660:40)
    at Array.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1081:40)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:163:36)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1823:50)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1856:33)
    at AsyncLocalStorage.run (node:async_hooks:327:14)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1934:55)
TypeError: Cannot read properties of undefined (reading '')
    at resolveModuleMetaData (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:195:82)
    at serializeModuleReference (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1298:50)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1660:40)
    at Array.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1081:40)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:163:36)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1823:50)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1856:33)
    at AsyncLocalStorage.run (node:async_hooks:327:14)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1934:55) {
  digest: '1544633764'
}

Expected Behavior

The page should render normally.

Link to reproduction

https://github.com/james-elicx/nextjs13-client-server-error-reproduction

To Reproduce

  1. Run the Next.js app in development mode.
  2. Visit root server component page, i.e. /
  3. Visit client component page, i.e. /client-page
  4. Visit root server component page, i.e. /

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:67
  • Comments:48 (8 by maintainers)

github_iconTop GitHub Comments

34reactions
timneutkenscommented, Nov 1, 2022

This issue has been triaged and we’re looking into it. Please keep comments to trying to resolve the issue as you’re pinging everyone on the thread. If you’re running into it use the 👍 emoji reaction on the initial post.

18reactions
ijjkcommented, Nov 3, 2022

Hi, yes this should be corrected in the next release, we will update here when it is available!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'getInitialProps')
I found, if some function uses 'zlib' module in app.ts, and swcMinify=true in next.config.js, this error comes like above; If swcMinify=false, ...
Read more >
Uncaught TypeError: Cannot read properties of undefined ...
React : Uncaught TypeError: Cannot read properties of undefined (reading 'pathname') ; Provider store={store}> ; ConnectedRouter history={history} ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Cannot read properties of undefined (reading 'pathname')
The error "Cannot read properties of undefined (reading 'pathname')" occurs when we don't set the to prop on a Link component in React...
Read more >
cannot read properties of undefined navigate - You.com
html in a browser the home page loads fine but when I click the "Me" nav link, I get the error "Uncaught TypeError:...
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