question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows: `Maximum call stack size exceeded` when number of items in `anyOf` is more than 1700

See original GitHub issue

I have a schema where one of the field km04 is having 1700+ options, whenever I am trying to validate the object send from client, with 1700+ options for the km04 field, it is specifically throwing an error in windows for Maximum call stack, this error is not replicable in mac, or even in windows if we reduce the number of options available for the km04 field below 1700.

here is the sample schema, schema.txt

The version of Ajv you are using 6.12.3

The environment you have the problem with Windows

Your code (please make it as small as possible to reproduce the issue) ajv.validate(schema, body);

If your issue is in the browser, please list the other packages loaded in the page in the order they are loaded. Please check if the issue gets resolved (or results change) if you move Ajv bundle closer to the top It is not in browser

Results in node.js v8+ Maximum call stack size exceeded

Results and error messages in your platform

Maximum call stack size exceeded

\node_modules\\ajv\\lib\\compile\\index.js:120:26)
   at Ajv.compile (\node_modules\\ajv\\lib\\compile\\index.js:55:13)
   at Ajv._compile (\node_modules\\ajv\\lib\\ajv.js:348:27)
   at Ajv.validate (\node_modules\\ajv\\lib\\ajv.js:96:36)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
epoberezkincommented, Aug 25, 2021

yes, semantically they are equivalent in this case (value is noop, it’s just metadata that can be provided some other way, e.g. as a map), but the generated code is very different (and enum is way more efficient).

1reaction
epoberezkincommented, Jul 22, 2021

It’s a fundamental call stack depth restriction given which code ajv has to generate without allErrors mode. I am quite reluctant to make compilation asynchronous to be honest…

One more idea is to simply increase the call stack size in nodejs (not 100% sure how many calls it makes per schema level as it compiles, but probably less than 10, so 10-20k should be enough) - please let me know if you try it what stack size makes it compile without any other changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Maximum call stack size exceeded error
It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you...
Read more >
JavaScript RangeError: Maximum Call Stack Size Exceeded
The RangeError: Maximum call stack size exceeded is thrown when a function call is made that exceeds the call stack size. This can...
Read more >
Getting a "maximum call stack size exceeded" and b...
I am getting a "maximum call stack size exceeded" error on my app when using an iOS device and the Powerapps app that...
Read more >
RangeError: Maximum call stack size exceeded
The “detail” component of the tree editor could then be rendered via JSON Forms. If you further want to go down the route...
Read more >
JavaScript Error: Maximum Call Stack Size Exceeded
If you see the “Maximum Call Stack Size Exceeded” error, there's likely a problem with a recursive function within your JavaScript code. More ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found