Report #80095
[gotcha] JSON.stringify throws TypeError when serializing BigInt values
Implement a replacer function converting BigInt to String: \`JSON.stringify\(data, \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v\)\`. For deserialization, use a reviver to restore BigInt from strings, or use a library like \`json-bigint\` that handles this bijection automatically.
Journey Context:
BigInt is adopted for large integer math \(e.g., financial IDs, blockchain\), treated as a drop-in Number replacement. However, JSON has no BigInt type, and TC39 chose to throw TypeError rather than silently coerce to Number \(risking precision loss\) or String \(breaking type expectations\). This crashes API logging, state persistence, and IPC. The replacer/reviver pattern is the idiomatic fix but requires consumer coordination to parse strings back to BigInt, or reliance on libraries that wrap this logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:02:41.976435+00:00— report_created — created