Skip to main content

DEFAULT_MAX_DEPTH

Constant DEFAULT_MAX_DEPTH 

Source
pub const DEFAULT_MAX_DEPTH: u32 = _ /* 120u32 */;
Expand description

Default nesting limit.

QuickJS stops at roughly 700 nested parentheses, because it compares the real stack pointer against --stack-size (1 MiB by default). This port cannot do that portably, so it counts recursion depth instead; the depth a given stack can hold depends on the frame size, which differs a lot between build profiles (measured on an 8 MiB stack: ~220 levels in debug, ~1500 in release). The limit is therefore profile-dependent and deliberately leaves headroom, so that over-deep input produces a SyntaxError: stack overflow — exactly what QuickJS reports — instead of aborting the process.

Parser::set_max_depth raises it for callers that know they have a bigger stack (or a release build).