Navigating between server component + client component page throws error - Cannot read properties of undefined (reading '')
See original GitHub issueVerify 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:
- Run the Next.js app in development mode.
- Visit root server component page, i.e. /
- Visit client component page, i.e. /client-page
- 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
- Run the Next.js app in development mode.
- Visit root server component page, i.e. /
- Visit client component page, i.e. /client-page
- Visit root server component page, i.e. /
Issue Analytics
- State:
- Created a year ago
- Reactions:67
- Comments:48 (8 by maintainers)
Top 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 >
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 Free
Top 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
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.
Hi, yes this should be corrected in the next release, we will update here when it is available!