Report #10856
[gotcha] JSON.stringify throws TypeError on BigInt values
Pass a replacer function to convert BigInt to String: JSON.stringify\(obj, \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v\)
Journey Context:
Developers assume BigInt serializes like Number because both are numeric primitives, but the ECMAScript spec explicitly forbids serializing BigInt to prevent accidental precision loss in systems lacking BigInt support. The replacer approach handles nested structures cleanly; manual pre-stringification does not. Libraries like json-bigint exist but add bundle size and interoperability risks. Converting to string is the safest cross-language contract.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:48:37.857215+00:00— report_created — created