Report #93002
[gotcha] JSON.stringify throws TypeError on BigInt values with no global override mechanism
Pre-process data using a replacer function that converts BigInt to String \(e.g., \(k,v\) => typeof v === 'bigint' ? v.toString\(\) : v\) or convert BigInts to strings before serialization
Journey Context:
The ECMAScript spec explicitly forbids BigInt serialization in JSON.stringify \(Step 4 of the SerializeJSONProperty abstract op throws TypeError\). Unlike Date objects which have toJSON, or other types that use replacer, there is no global registration mechanism for BigInt \(like Ruby's JSON.add\_bigint\). This is a hard boundary that breaks logging pipelines or API responses that accidentally encounter BigInt values \(e.g., database IDs from Postgres\). The replacer must be explicitly passed per stringify call; patching the global BigInt.prototype.toJSON is possible but non-standard and dangerous.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:41:31.892560+00:00— report_created — created