Open nphmuller opened 21 hours ago
Can you apply the binary search approach to debugging. Take your root page / layout and make them just show basic “hello” and “world”. The issue should go away.
then reintroduce the code bit by bit. So introduce your root layout but keep the page as just “world”. This will allow you to determine if the issue exists in the layout or in the page / the nested pages.
Slowly uncomment parts of your code bit by bit until the issue comes back. Then you can identify what erroneous code is causing the issue.
Turbopack works fine for me. But when I first tried to set it up I had to do the above approach to figure out what was causing me issues.
I hope this advice helps. It can be applied to many problems.
You’re totally right and I should have explained this better. I tried to follow this approach when making the repro, and the part that is causing the error is adding <InfoSharp />
(or any other icon from the library) at that specific place in createTheme()
. When I render the icon directly in my component, instead of referencing it in createTheme()
, the error doesn't happen.
When I’m at my pc again I’ll edit my post and look further. But I should have at least mentioned this before in my repro…
I’ll also try to repro this issue in plain code without using MUI, but I haven’t be able to so far.
Rewrote the repro from scratch, without any dependencies. Let me know if I can do more to clarify! :)
Link to the code that reproduces this issue
https://github.com/nphmuller/next15-turbo-maxstack-repro
To Reproduce
npm run dev
RangeError: Maximum call stack size exceeded
.If you remove --turbo in package.json there is no error.
Main repro: https://github.com/nphmuller/next15-turbo-maxstack-repro/blob/master/app/wrapper.tsx
Manual repro:
layout.tsx:
Current vs. Expected behavior
Expected: No error
Current: Error in console. Full stack trace:
Provide environment information
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I also tested against the latest preview release (
15.0.2-canary.7
) and the issue still repros.It seems that the value of the _owner key of the to be cloned component has a different value between webpack (null) and turbopack (see below). The value in turbopack seems to cause an infinite loop in the deepClone code.
The value of _owner when ran via turbopack is:
While the repro looks pretty exotic, it's mainly there to have an example without any external dependencies.
Here's a more practical example of the code that originally caused the error: https://github.com/nphmuller/next15-turbo-maxstack-repro/blob/0d1bfdfbc86441fc0603c151e36ecfac4892ace9/app/wrapper.tsx