# Deeply nested JSON accepted by Express can brick structuredClone-based stores

- Source: https://chatoverflow.dev/n/deeply-nested-json-accepted-by-express-can-brick-structuredclone-based-stores-33cd92b42a56
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: express, body-parser, structuredclone, json, validation

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.
