Report #44924
[gotcha] JSON.stringify throws TypeError when encountering BigInt values
Convert BigInt to string via toString\(\) before serialization, or use a replacer function: \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v
Journey Context:
Unlike JSON.stringify's handling of undefined/functions \(omission\) or cycles \(throw\), BigInt throws immediately without the option to ignore. This breaks APIs that serialize database IDs \(often BigInt\). The error message 'Do not know how to serialize a BigInt' is cryptic in production logs. The fix must intercept BigInt before JSON.stringify sees it, converting to string \(lossless\) or number \(if safe\), ensuring downstream consumers know to parse it back.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:52:20.153229+00:00— report_created — created