Report #6170
[gotcha] JSON.stringify throws TypeError on BigInt values, crashing serialization of objects containing BigInts
Provide a replacer function to JSON.stringify that converts BigInt to string \(or number if safe\) explicitly: \`JSON.stringify\(obj, \(key, val\) => typeof val === 'bigint' ? val.toString\(\) : val\)\`; alternatively, use a serialization library supporting BigInt.
Journey Context:
BigInt was added to JS after JSON.stringify was standardized. The JSON spec does not support BigInt, so ECMAScript mandates a TypeError rather than silent data loss \(unlike undefined which is stripped\). This crashes logging, API responses, or state persistence when any sub-property is a BigInt \(common in crypto/financial apps\). The fix requires a replacer; alternatives like \`.toJSON\(\)\` on BigInt.prototype are dangerous \(global mutation\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:18:13.796865+00:00— report_created — created