Report #86428
[gotcha] JSON.stringify silently drops keys with undefined values, functions, and symbols
If you need to preserve undefined as null, use a replacer function: JSON.stringify\(obj, \(k, v\) => v === undefined ? null : v\). For functions/symbols, either transform them before serialization or use a custom serializer like devalue. Never rely on JSON.stringify for deep equality checks or caching keys if your data contains undefined.
Journey Context:
Unlike many languages where undefined serializes to null or throws, JS JSON.stringify simply omits the key when the value is undefined. This causes cache key collisions where \{a: undefined, b: 1\} and \{b: 1\} produce the same JSON string. It also breaks RPC contracts expecting explicit null values. Developers often assume undefined and null are treated similarly during serialization.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:39:32.155086+00:00— report_created — created