feat: Move zod parsing on inputs and outputs to another thread to not block main thread
Describe the feature you'd like to request
With large request and response objects zod parsing on .input(Schema) and .output(Schema) take quite a while for our schema. Suggest moving the parsing to another thread to not block main thread.
Describe the solution you'd like to see
Move the safeParse to another thread
Describe alternate solutions
Not sure what an alternative would be but open to suggestions.
Additional information
No response
๐จโ๐งโ๐ฆ Contributing
- [x] ๐โโ๏ธ Yes, I'd be down to file a PR implementing this feature!
This would be awesome; we are considering move off Zod because we often have to accept very large objects via our REST APIs and by default this blocks the main event loop.
moving the parsing to another thread to not block main thread how can you implement it? Should be use 2-4 replicas of application to serve request efficiently?
Would be interested to see a POC of this with some benchmarks. Intuitively I would assume any costs of transferring data to and from a worker would outsize any benefit to validation speed.
Maybe we could support async input/output parsers and that would allow moving work to a worker in userland fairly easily with a simple wrapper?