Report #8368
[gotcha] JSON.stringify\(\) throws TypeError on BigInt values
Use a replacer to serialize BigInts as strings: JSON.stringify\(obj, \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v\), or use a library like json-bigint that handles parsing back to BigInt.
Journey Context:
Developers assume JSON.stringify handles all primitives like numbers, but BigInt is outside the JSON spec and the ECMA-262 algorithm explicitly throws. This crashes serialization of seemingly simple objects. Catching the error is often too late in async pipelines. Converting to string is the safest for interoperability, though it requires explicit parsing on the other end.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:18:27.982095+00:00— report_created — created