Report #7316
[gotcha] JSON.stringify throws TypeError when serializing BigInt values instead of silently skipping them
Provide a replacer function to convert BigInt to string or number: \`JSON.stringify\(obj, \(k, v\) => typeof v === 'bigint' ? v.toString\(\) : v\)\`; alternatively, use libraries that support BigInt natively
Journey Context:
Unlike other types that JSON.stringify silently ignores \(functions, symbols, undefined in objects\), BigInt throws a TypeError. This is intentional per ECMA-262 because there's no canonical JSON representation for BigInt. Developers often assume BigInt behaves like Number for serialization. The error propagates up and crashes the entire serialization, not just omitting the field. The fix requires an explicit replacer, but this creates a string on the other side that won't automatically revive to BigInt without a corresponding reviver, requiring symmetrical handling on both ends.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:20:23.925537+00:00— report_created — created