You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There has been reports of the ajv.compile method causing memory leaks, an issue that will directly affect any user making use of the validation methods provided by this library, as well as anyone using express-oas-validator. More information can be found in the links below:
For what it's mentioned in the comments of these threads, those memory leaks could origin in a wrong usage of the library, not so much a bug on it. Thus, updating our dependency to the latest version of the ajv library doesn't seem to have fixed anything.
We should double check the links above for more information and try to find out a more efficient way to use it so we can prevent those leaks from happening. Maybe we're missing some option in the configuration object that could help fixing this issue.
Posible solutions
Probably we should find a way to cache the schemas, as mentioned here in the docs. What we currently have forces the schemas to be re-compiled everytime we call either validateResponse or validateRequest, which could be pretty unefficient, specially on APIs with a large amount of them and / or that receive a lot of requests.
It may be convenient to expose a new method in charge of generating the compiled schema, and modify validateResponse and validateRequest to receive the result as a parameter. This way we could avoid re-compiling the data everytime we want to perform a validation. After all, the content of the schema is not gonna change on run time, meaning it should be enough by compiling it once.
The text was updated successfully, but these errors were encountered:
There has been reports of the
ajv.compile
method causing memory leaks, an issue that will directly affect any user making use of the validation methods provided by this library, as well as anyone usingexpress-oas-validator
. More information can be found in the links below:For what it's mentioned in the comments of these threads, those memory leaks could origin in a wrong usage of the library, not so much a bug on it. Thus, updating our dependency to the latest version of the
ajv
library doesn't seem to have fixed anything.We should double check the links above for more information and try to find out a more efficient way to use it so we can prevent those leaks from happening. Maybe we're missing some option in the configuration object that could help fixing this issue.
Posible solutions
Probably we should find a way to cache the schemas, as mentioned here in the docs. What we currently have forces the schemas to be re-compiled everytime we call either
validateResponse
orvalidateRequest
, which could be pretty unefficient, specially on APIs with a large amount of them and / or that receive a lot of requests.It may be convenient to expose a new method in charge of generating the compiled schema, and modify
validateResponse
andvalidateRequest
to receive the result as a parameter. This way we could avoid re-compiling the data everytime we want to perform a validation. After all, the content of the schema is not gonna change on run time, meaning it should be enough by compiling it once.The text was updated successfully, but these errors were encountered: