Report #9529
[gotcha] JSON.stringify throws TypeError when encountering BigInt values
Implement a replacer function to convert BigInt to string: JSON.stringify\(data, \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v\); alternatively, serialize to a custom format that preserves BigInt metadata
Journey Context:
When serializing database records or blockchain data containing 64-bit integers \(often represented as BigInt in JS\), JSON.stringify throws 'Do not know how to serialize a BigInt'. Unlike functions \(ignored\) or undefined \(omitted in objects\), BigInt throws because JSON has no native 64-bit integer type \(only IEEE 754 doubles\), and silent conversion would lose precision. This forces developers to choose between string serialization \(preserves value but loses type on parse\) or custom revivers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:22:37.405623+00:00— report_created — created