When I use a client component in root layout the server returns a 500 error
elsueno opened this issue · comments
What is the problem?
When I use a client component in root layout the server returns a 500 error but everything seems to be working properly.
So just the response status seems to be wrong.
Paste all your error logs here:
GET http://127.0.0.1:3000/ 500 (Internal Server Error)
Paste all relevant code snippets here:
See below
What are detailed steps to reproduce this?
Checkout repo that demonstrates the bug and start server
git clone https://github.com/elsueno/blitz-209-bug.git
cd blitz-209-bug
npm install
npx blitz@2.0.9 dev
Now open http://localhost:3000 in your browser - everything seems to be working properly but this error is logged in the browser console
GET http://127.0.0.1:3000/ 500 (Internal Server Error)
Run blitz -v
and paste the output here:
Output of "npx blitz@2.0.9 -v"
Blitz version: 2.0.9 (local)
Linux 5.19 | linux-x64 | Node: v21.0.0
Package manager: npm
System:
OS: Linux 5.19 Pop!_OS 22.04 LTS
CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
Memory: 4.16 GB / 14.86 GB
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 21.0.0 - ~/.nvm/versions/node/v21.0.0/bin/node
Yarn: 1.22.19 - ~/.nvs/node/18.10.0/x64/bin/yarn
npm: 10.2.0 - ~/.nvm/versions/node/v21.0.0/bin/npm
npmPackages:
@blitzjs/auth: 2.0.9 => 2.0.9
@blitzjs/next: 2.0.9 => 2.0.9
@blitzjs/rpc: 2.0.9 => 2.0.9
@prisma/client: 5.4.2 => 5.4.2
blitz: 2.0.9 => 2.0.9
next: 14.1.4 => 14.1.4
prisma: 5.4.2 => 5.4.2
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
typescript: ^4.8.4 => 4.9.5
Please include below any other applicable logs and screenshots that show your problem:
No response
@elsueno I installed your repo locally and it ran fine for me. Do the error logs in the terminal give any hints? I'm not sure what the default logging level Blitz sets, but perhaps overriding it in blitz-server.ts: BlitzLogger({ minLevel: 1 })
may yield more information.
I can confirm the error based on the demo app https://github.com/elsueno/blitz-209-bug
The error is only visible in the browser, not the terminal.
- Layout with
<User>
client component https://github.com/elsueno/blitz-209-bug/blob/main/src/app/layout.tsx - User client component https://github.com/elsueno/blitz-209-bug/blob/main/src/app/components/User.tsx
@elsueno I installed your repo locally and it ran fine for me. Do the error logs in the terminal give any hints? I'm not sure what the default logging level Blitz sets, but perhaps overriding it in blitz-server.ts:
BlitzLogger({ minLevel: 1 })
may yield more information.
The error is logged in the browser console. I've updated the ticket to make this more clear.