From a0fb802bd2490713fbe0f5cd0823bb85fe7165df Mon Sep 17 00:00:00 2001 From: coyaSONG <66289470+coyaSONG@users.noreply.github.com> Date: Sat, 18 Jul 2026 00:41:54 +0900 Subject: [PATCH] fix: serialize bigint values in stringifyCircular --- .changeset/tidy-bigint-inspection.md | 5 +++++ packages/effect/src/Inspectable.ts | 2 ++ packages/effect/test/Inspectable.test.ts | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 .changeset/tidy-bigint-inspection.md diff --git a/.changeset/tidy-bigint-inspection.md b/.changeset/tidy-bigint-inspection.md new file mode 100644 index 00000000000..4d687ef8af4 --- /dev/null +++ b/.changeset/tidy-bigint-inspection.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +Handle bigint values in circular JSON serialization. diff --git a/packages/effect/src/Inspectable.ts b/packages/effect/src/Inspectable.ts index 9bab2d1e9c4..61f28482bd9 100644 --- a/packages/effect/src/Inspectable.ts +++ b/packages/effect/src/Inspectable.ts @@ -229,6 +229,8 @@ export const stringifyCircular = (obj: unknown, whitespace?: number | string | u : cache.push(value) && (redactableState.fiberRefs !== undefined && isRedactable(value) ? value[symbolRedactable](redactableState.fiberRefs) : value) + : typeof value === "bigint" + ? String(value) + "n" : value, whitespace ) diff --git a/packages/effect/test/Inspectable.test.ts b/packages/effect/test/Inspectable.test.ts index 2170415c4e1..a1a9e2f227b 100644 --- a/packages/effect/test/Inspectable.test.ts +++ b/packages/effect/test/Inspectable.test.ts @@ -151,6 +151,12 @@ describe("Inspectable", () => { }) }) + describe("stringifyCircular", () => { + it("serializes bigint values", () => { + strictEqual(Inspectable.stringifyCircular({ value: 123n }), `{"value":"123n"}`) + }) + }) + describe("toString", () => { it("primitives", () => { strictEqual(Inspectable.format(null), "null")