Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout option on refParser.validate() #134

Closed
domharrington opened this issue Aug 29, 2019 · 1 comment
Closed

Timeout option on refParser.validate() #134

domharrington opened this issue Aug 29, 2019 · 1 comment

Comments

@domharrington
Copy link

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

@jonluca
Copy link
Collaborator

jonluca commented Mar 6, 2024

I think this is best handled by the callers of the library - we have async functions now, which let you await the result, although admittedly most of the processing is still fairly synchronous. I'd be open to hearing how a timeout might be implemented in a way that doesnt impact the performance of the synchronous case though

@jonluca jonluca closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants