diff --git a/src/bun.js/ConsoleObject.zig b/src/bun.js/ConsoleObject.zig index a1cfeb510359..c9a7361ee4c2 100644 --- a/src/bun.js/ConsoleObject.zig +++ b/src/bun.js/ConsoleObject.zig @@ -1136,7 +1136,7 @@ pub const Formatter = struct { pub fn canHaveCircularReferences(tag: Tag) bool { return switch (tag) { - .Function, .Array, .Object, .Map, .Set, .Error, .Class, .Event => true, + .Function, .Array, .Object, .Map, .Set, .Error, .Class, .Event, .JSX => true, else => false, }; } diff --git a/test/js/bun/util/inspect.test.js b/test/js/bun/util/inspect.test.js index 32a70af30183..54a43f17e818 100644 --- a/test/js/bun/util/inspect.test.js +++ b/test/js/bun/util/inspect.test.js @@ -316,6 +316,24 @@ it("jsx with fragment", () => { expect(input).toBe(output); }); +it("jsx with circular reference in key", () => { + const el = { $$typeof: Symbol.for("react.element"), type: "div", key: null, ref: null, props: {} }; + el.key = el; + expect(Bun.inspect(el)).toContain("[Circular]"); +}); + +it("jsx with circular reference in props", () => { + const el = { $$typeof: Symbol.for("react.element"), type: "div", key: null, ref: null, props: {} }; + el.props.foo = el; + expect(Bun.inspect(el)).toBe("
"); +}); + +it("jsx with circular reference in children", () => { + const el = { $$typeof: Symbol.for("react.element"), type: "div", key: null, ref: null, props: {} }; + el.props.children = [el]; + expect(Bun.inspect(el)).toBe("