Open jokesterfr opened 3 years ago
I just started using this library. I hope it does not contain any more surprises like this!
This is the only edge case I had so far, same for my colleagues. This lib is pretty reliable, but for sure perfs should be carefully tested to avoid anything like this.
Thanks for the detailed example @jokesterfr!
I just started using this library. I hope it does not contain any more surprises like this!
I am sure as with any code in the world, this lib contains more surprises like this. However, feel free to send a fix for every problem you find. :)
@jokesterfr that's one of the nicest bug reports I have ever seen.
If someone finds this issue, I do not think that it is only related to the IsOptional
decorator, because I also see the issue without using them. We use the standalone validate
function and only simple validators. We are at a stage where we can't use class-validator any longer, due to this bug.
Same here. We moved to AJV and json-schema, in cunjunction with OpenApi v3.1 spec first process. Types are generated on the fly from it.
Description
While using this library, I encountered a memory issue and a blocked Node.js eventloop, which lead my server to crash a lot of times. Digging, I found out this was my usage of inheritance and the non-decorator usage of
IsOptional()
which lead me to this issue in combination withplainToClassFromExist()
calls.I made a complete test file to stress this out, and isolate the issue from my running code. So you can easily reproduce it yourselves:
Calling the test give these results:
Which can be interpreted this way:
I tested out this with various items length:
Hence the logarithmic graph of these measures:
Minimal code-snippet showcasing the problem
Expected behavior
No performance difference between test 1, 2 and 3.
Actual behavior
Crashing the process after many iterations on class-validator
validate()
calls.