Fix stack overflow when inspecting circular JSX elements#30629
Conversation
The JSX formatter in Bun.inspect did not participate in circular reference detection, causing infinite recursion and a stack overflow when a React element's props or children referenced the element itself. Also fix a null unwrap panic when props is not an object.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughJSX console formatting gains circular reference detection and improved robustness: the formatter now recognizes ChangesJSX Circular Reference and Props Handling
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
|
Duplicate of #29709, which has the same fix plus the equivalent change in |
What does this PR do?
Fixes a stack overflow crash in
Bun.inspect/console.logwhen formatting a React element whosepropsorchildrenform a cycle back to the element itself.The JSX formatter was not included in
canHaveCircularReferences(), so the visited-map check never ran for.JSXtags and the formatter recursed until the stack blew out.Also fixes a null-unwrap panic when
propsis set to a non-object value — the formatter assumedpropswas always an object and didprops.getObject().?. Now it skips prop iteration whenpropsis not an object.How did you verify your code works?
Added regression tests to
test/js/bun/util/inspect.test.jscovering circularprops, circularchildren, and non-objectprops.Found by Fuzzilli (fingerprint
380dfde18006ab21).