Context
The math parser in src/lib/litegraph/src/utils/mathParser.ts uses recursive descent parsing which can cause stack overflow with deeply nested parentheses (verified to crash around depth ~3000).
Requested Enhancement
Add a depth counter to prevent stack overflow from pathological input:
- Increment counter on each
( encountered
- Bail out if depth exceeds a reasonable limit (e.g., ~200)
- Return
undefined for expressions that exceed the limit
Background
While unlikely in typical widget input scenarios, adding this safeguard would harden the parser against edge-case inputs.
References
┆Issue is synchronized with this Notion page by Unito