Report #58551
[gotcha] JSON.stringify silently drops undefined/functions/symbols or throws on BigInt/circular structures
Use a replacer function to handle BigInt \(convert to string\), handle circular references with a library \(flatted\), or use structuredClone then serialize if environment supports it
Journey Context:
JSON.stringify follows the ECMAScript spec strictly: it skips object keys with undefined values, returns undefined for top-level undefined, throws TypeError for BigInt \(since no JSON representation exists\), and throws TypeError for circular references. This surprises developers who expect undefined to become null or BigInt to be stringified. The replacer argument can handle BigInt by converting to string, but must be done carefully. Circular references require a WeakMap tracking pattern as seen in flatted/library implementations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:46:05.536622+00:00— report_created — created