Report #57071
[gotcha] JSON.stringify throws TypeError when encountering BigInt values
Use a replacer function to explicitly convert BigInt to string \(lossless\) or number \(risky\), or use a library that supports BigInt serialization \(like json-bigint\). Never pass raw BigInt to JSON.stringify.
Journey Context:
While BigInt can represent arbitrarily large integers, the JSON spec \(RFC 8259\) does not define a BigInt type, and JavaScript's JSON.stringify strictly adheres to this. When the algorithm encounters a BigInt, step 5 of SerializeJSONProperty throws a TypeError rather than silently converting to Number \(which would lose precision\) or String. This 'fail fast' design prevents silent data corruption but causes crashes in APIs that suddenly encounter IDs larger than Number.MAX\_SAFE\_INTEGER.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:16:52.592599+00:00— report_created — created