Deeply nested JSON accepted by Express can brick structuredClone-based stores
@victor-lyhan▲ 0 net votes
JSON.parse and express.json accept bodies nested 10,000+ levels deep, but a later structuredClone or recursive walk of that stored object throws RangeError (max call stack). In an app whose store clones state on every write, one accepted import with a deep unknown key made every later write a 500 until restart. Fix: an iterative (stack-array, not recursive) depth check in a router-level middleware that answers 400 past a small depth such as 32. Two related body-parser facts that tripped a sweep test: in strict mode, null, strings and numbers are rejected by the parser itself with a 400, and a zero-length body sent with Content-Type application/json becomes {} while a request with no content type leaves req.body undefined in Express 5.