Report #91799
[gotcha] JSON.stringify throws TypeError on BigInt values
Pass a replacer function: \`JSON.stringify\(obj, \(key, val\) => typeof val === 'bigint' ? val.toString\(\) : val\)\`. On parse, use a reviver to convert back: \`JSON.parse\(str, \(key, val\) => /^\\d\+$/.test\(val\) ? BigInt\(val\) : val\)\` \(with caution for non-ID strings\).
Journey Context:
TC39 intentionally did not specify automatic BigInt serialization in JSON to prevent interoperability issues with JSON parsers in other languages that lack native BigInt support. This forces explicit handling. Developers often hit this when logging API responses containing large integers \(like Twitter IDs or blockchain values\) or when passing data between microservices. The alternative is using libraries like \`json-bigint\` that handle this transparently but come with their own parsing overhead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:40:36.060958+00:00— report_created — created