-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: prevent infinite recursion in Trans components (fixes #6937) #6939
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
Conversation
Fixes #6937 - Maximum call stack size exceeded error The issue was caused by passing JSX elements with children to the Trans component's components prop. When the translation string also contained the same tags, it created infinite recursion during interpolation. Changed all Trans components to use self-closing tags (e.g., <code />) instead of tags with children (e.g., <code>{value}</code>) to prevent the recursion issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.
| <Trans | ||
| i18nKey="chat:codebaseSearch.wantsToSearchWithPath" | ||
| components={{ code: <code></code> }} | ||
| components={{ code: <code /> }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good fix! The change from <code>{value}</code> to <code /> correctly prevents the infinite recursion. However, have you checked if there are other Trans components in the codebase that might have the same pattern? A quick search for similar patterns across the codebase would ensure we've caught all instances of this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All instances are covered
| <Trans | ||
| i18nKey="chat:codebaseSearch.wantsToSearchWithPath" | ||
| components={{ code: <code></code> }} | ||
| components={{ code: <code /> }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment here explaining why self-closing tags must be used instead of tags with children. Something like:
| components={{ code: <code /> }} | |
| // Note: Use self-closing tags in components prop to prevent infinite recursion | |
| // when translation strings contain the same tags (e.g., <code>) | |
| components={{ code: <code /> }} |
This would help prevent future developers from reintroducing this issue.
| <Trans | ||
| i18nKey="chat:modes.wantsToSwitchWithReason" | ||
| components={{ code: <code>{tool.mode}</code> }} | ||
| components={{ code: <code /> }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the existing tests pass, would it be worth adding a specific test case that would have caught this infinite recursion bug? This could help prevent regression in the future.
|
This seems to be a reasonable fix but it would be great to figure out consistent repro steps for the issue to properly test this solution |
This PR fixes the "Maximum call stack size exceeded" error that occurs when executing subtasks in RooCode.
Problem
The issue was caused by passing JSX elements with children to the Trans component's
componentsprop. When the translation string also contained the same tags (e.g.,<code>), it created infinite recursion during the interpolation process in react-i18next.Solution
Changed all Trans components in ChatRow.tsx to use self-closing tags (e.g.,
<code />) instead of tags with children (e.g.,<code>{value}</code>) in the components prop. This prevents the infinite recursion while maintaining the same functionality.Changes Made
webview-ui/src/components/chat/ChatRow.tsx<code>{variable}</code>with<code />in the components propTesting
Fixes #6937
Important
Fixes infinite recursion in
Transcomponents inChatRow.tsxby using self-closing tags incomponentsprop to prevent call stack errors.Transcomponents inChatRow.tsxby using self-closing tags incomponentsprop.TransinChatRow.tsxto use<code />instead of<code>{value}</code>.valuesprop.Transcomponents.This description was created by
for e1f51d7. You can customize this summary. It will automatically update as commits are pushed.