json-schema-ref-parser
json-schema-ref-parser copied to clipboard
Timeout option on `refParser.validate()`
Hey,
Thanks so much for your excellent work on this module and swagger-parser, we're extensive users of both @ ReadMe. We occasionally accept very large files from our customers which can take a prohibitively long time to validate(), which blocks the event loop and affects performance for other requests.
We've gotten around this by performing the validation in a forked child process, and adding a setTimeout() in the parent process. If the setTimeout gets hit before the child process can validate and dereference, then we return an error and kill the child.
This has worked surprisingly well for us, but has added some complexity to our code. Would it be possible to add a timeout anywhere inside this module? Maybe by utilising process.nextTick so the validation doesn't block the event loop? I've not looked into the code of this module before, so I may be wildly off the mark here, but if I can help out in any way then I'd love to!
Looking forward to hearing your thoughts. Dom