[Urgent] Error: Maximum call stack size exceeded ... in Header Component

The header app of my Retool application, which was working yesterday, and for which I have not added any new code, now says "Error: Maximum call stack size exceeded ...


The bizarre thing is that the buttons on the header are still working, so I think it is an error with the navigation component.

Can someone from Retool please help look at this or come up with a temporary workaround? It is paralyzing our staff from navigating to the different Retool apps.

1 Like

Hi! Would you mind sending me your app json at ibork@retool.com?

2 Likes

Same issue, any resolution?

Having the same issue

Isabella was super helpful, and able to help me create a working module! Perhaps she could help you too?

This is what she and the engineering team found.

I talked to the engineer who has been working on updating the "menu items' editorβ€”it seems like there's a very odd edge case where menu items can have the same key and parent key (basically referencing themselves as the parent) which causes infinite recursion (example below).

He hasn't decided on a fix yet just because this is an unintended app state, but he manually edited your header module to resolve this problem. You could maybe try importing the module JSON as an app, and then importing this fixed header module instead of the old one?

1 Like

+1 to what Jeffrey said! If you send me your app JSON and your module's app JSON at ibork@retool.com I can look into it for you! You could also try Jeffrey's solution and see if it works!

Sent on Friday, I can resend if needed

It seems like it's the same issue as Jeffrey where your navigation component ended up in a weird state where one of the nodes ended up pointing to itself. We're trying to pinpoint how navigation components could end up in this corrupted state and push out a fix for that, but in the meantime if you recreate the navigation component from scratch (not by duplicating) the error should go away. Hopefully that's not too much work!

Hi! I have the same issue.
Any tips on how can I edit the module json myself to fix this problem?

Hi! We are actively working to fix this issue and can hopefully get something out quick. In the meantime, if you are willing to do the following steps, you should be able to export your problematic app/module, manually edit, and then reimport to resolve.

Once you have exported your app and open it in your editor, you are looking for two fields: _keyByIndex and _parentKeyByIndex. This error is caused by some edge cases where items can somehow self reference, aka _keyByIndex[index] and parentKey[index] will have the same value.

For instance, in this example we identify the problem as being indices 11 and 12 for both arrays.

"_keyByIndex":["foo1","","","","foo2","","","","","","","foo3","foo3","","",""]
"_parentKeyByIndex":["","foo1","foo1","foo1","","foo2","foo2","foo2","foo2","foo2","foo2","","foo3","foo3","foo3","foo3"]

index 11 has a key of foo3 and an empty parentKey (this makes sense, as this is a top level navigation item and it does not itself have a parent)
index 12 has a key of foo3 and a parentKey of "foo3". This does not make sense, as this item is in fact a nested menu item and its key should actually be empty.

The fix in this case is to delete the second "foo3" value (replace with "") in the _keyByIndex array in the 12th index. You will have to repeat this operation for any other occurrences in your app json, depending on how many times this occurs in your navigation component. Additionally, we save both an escaped and unescaped version of the app template, so you will need to do the delete in two places (if you look for _keyByIndex you will see an escaped version as well that resembles ,\"_keyByIndex\")

Once you have made the update and saved the file, feel free to re upload into Retool and it should hopefully resolve the issue. If this did not work, you have a complicated example, or you are otherwise having trouble doing this change yourself, feel free to email me at justin.chen@retool.com and I will help fix it for you!

1 Like

Hi @Justin_Chen ,
Thanks for the quick reply. Will try it myself and let you know how it works out.

1 Like

Worked like a charm. Thanks!

For other people facing this, I changed the value for _keyByIndex 3 times (1 escaping quotes) but I had to make no changes to _parentKeyByIndex.

2 Likes

Amazing, I'm glad it worked for you!

1 Like

We faced the same issue in one of our apps. Modifying the json and re-importing it fixed the issue. Thanks for the suggestions.

1 Like