New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigating between server component + client component page throws error - Cannot read properties of undefined (reading '') #41806
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
I have the same issue with 2 client component pages. Even when I change the page manually in the address bar, the same error occurs, mainly when trying to open the page second time. I've found a workaround to continue my testing of Next.js 13. If I run |
I started a project from scratch with npx create next and the error appear either if the index page renders some "use client" or if 2 other pages have "use client". It does not fail if one subpage has "use client". So basically; index page with use client = fail This is tested with all default files in the app/ folder and the pages are loading components from a components folder that has the use clients set. |
I can confirm --turbo removes the problem in my test case |
Rather interestingly, They remain when trying to do |
This is expected behavior since turbopack is used only in dev. So the issue is actual. |
I started a project from scratch with |
Maybe OS problem? I can build example project(https://github.com/moodiest/nextjs13-client-server-error-reproduction) on m1 macbook air, but it fails on windows 10. build message on mac, successbuild message on windows 10, errormessage
Can anyone test on different machines? |
It's certainly seeming that way. My build on windows 10 failed completely but succeeded when I used Ubuntu through WSL2. What I did find interesting though was that this appears to be a problem with webpack and Next.js 13, because using I imagine that when Turbopack supports building, this won't necessarily be as much of a problem, unless of course someone needs to be able to use webpack. |
I'm also getting an error on Windows 10 but only when navigating https://github.com/vercel/app-playground
|
I get the same problem on MacOS so it's not a Windows-specific problem. log
|
I've found out that in my case the error was caused by |
@mmiszy What happens when you run |
https://github.com/moodiest/nextjs13-client-server-error-reproduction has no |
I have the same problem but different error
|
also when I build the project I get this
|
I noticed when converted all client components and pages to server components (by deleting "use client") everything will work properly |
Ran into the same error while trying to run the Next13 Playground Demo App Probably a hacky solution but got the app running as expected by doing the following :
|
Yeah, I believe it is a webpack problem as using turbopack seems to function as expected. If you try building, you will most likely get the error again as the only option for building is webpack at the moment. Would you be able to confirm which OS you are using? |
For this, windows 11 |
Get the same error. In my case I try to use a client component inside a server component, which results in this error. This should be possible right? Server component inside server component works fine, but i need a client component to use event handlers and hooks. |
This comment was marked as off-topic.
This comment was marked as off-topic.
At first thought its below
but then the issue reoccurred after a while, so next/head seems unrelated or not the only culprit |
I ran in to the same issue. Build on Windows 11 failed completely. Failed occasionally in development mode too. Build successfully on WSL 2, but very slow in development mode. |
This comment was marked as off-topic.
This comment was marked as off-topic.
The only workarounds for Windows users appear to be using |
I tried using Windows subsystem linux or a dev machine (I use macOS now to run the dev environment and just remote in using VSCode) is the better solution |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
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. |
This is indeed OS related. The same codebase is working fine when using WSL, but on Windows does throw up this error consistently. Not sure if its related, on WSL get below warnings that are not shown on Windows. would below warning indirectly be preventing the error from occurring?
I still get below on server console in WSL but its not affecting UI currently
|
This workaround works, but hitting error with turbopack: i just erased the svg though. Error resolving URI imports: not implemented yet |
@schemburkar I encountered the issue on macos (ventura) as well |
I also experienced a similar issue on Windows 10 when trying to use the useState hook in a client component embedded in a server component. I received the same TypeError as @james-elicx, but all I had to do to fix the issue was give my useState hooks different default values.
UPDATE: This doesn't seem to work as consistently as I thought, as in some instances, the error still persists. UPDATE 2: I'm running 'next run dev --turbo' in VS Code's Javascript Debug Terminal using the configuration specified here: https://nextjs.org/docs/advanced-features/debugging. Under these constraints the error is also not appearing, irrespective of the value I use to initialize the state variables. UPDATE 3: Migrating to a later version of yarn, (I was still using v1) also (somehow) resolved the issue for me. I'm not sure how much these solutions will resolve problems across larger apps, but that's what worked for me. |
Windows 11, and can reproduce this constantly. The page does use 'use client' and imports useEffect, useRef and useState. Right now I can only debug and see changes by restarting npm run dev after every page load. If I try to load the page twice without a restart it throws this error. |
Hi, yes this should be corrected in the next release, we will update here when it is available! |
Hi this should be updated in |
Haven't had an issue with this since the update. Thank you so much. |
Can confirm so far W10 running next 13.0.2 I don't see this error! |
@chukwumaokere How about 13.0.3? Did you try it? |
The issue seems not resolved on 13.0.3:
|
This issue that was reported was specifically related to Windows only, can you create a new issue with a reproduction? I'm guessing you're using |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
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:
Result:
A white page and an error in my terminal/console.
Expected Behavior
The page should render normally.
Link to reproduction
https://github.com/james-elicx/nextjs13-client-server-error-reproduction
To Reproduce
The text was updated successfully, but these errors were encountered: