tdegrunt / jsonschema

JSON Schema validation
Other
1.83k stars 262 forks source link

Fix "maximum call stack size exceeded" when there are many errors #363

Closed osi-jehrlich closed 2 years ago

osi-jehrlich commented 2 years ago

Fixes #344.

Note: The included test simulates one million errors. To keep the tests running fast it does so using a custom keyword to produce all of the errors. This approach was over 7x faster than my efforts to use built-in keywords and large arrays/objects, but it still takes around 300ms on my laptop.

osi-jehrlich commented 2 years ago

Is there anything else needed or is there anything I can do to help move this along?

awwright commented 2 years ago

Yeah this looks reasonable. I vaguely recall there was a reason we avoided concat... I'll work on this on Monday. There's one other optimization I'd like to look at while I'm in there (see if we can share a pointer to the same errors object, when possible, which should be most cases except not/if/oneOf/anyOf, this should save some additional memory and GC).

awwright commented 2 years ago

@osi-jehrlich Landed in 1.4.1, please take a look and report how that works.

osi-jehrlich commented 2 years ago

Will do, thank you!

osi-jehrlich commented 2 years ago

Things are looking good so far. I'll let you know or submit a PR if anything comes up. Thanks again.