-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Built-in low-cost async to sync method #34918
Comments
Unclear description. What are you asking or saying? |
Looks like a duplicate of #30634 |
please review your question |
Given the way that Promises and async operations work within JavaScript and Node.js, converting those into sync blocking operations is not actually possible. The blocking to wait for completion would block the actual completion because the task queues would never be drained and the event loop would never turn to allow the Async ops to complete. There are ways you can come close to what you want using Worker threads but at a fairly steep performance and complexity price. If you believe there's a way to accomplish it in a reasonable way, pull requests are always welcome. |
How is |
Sidenote: If you just need sleep synchronously for a certain amount of time, this can now be achieved in pure JS: https://github.com/sindresorhus/sleep-synchronously/blob/1fe452b47e810cf21bbc67e022a70ab925603759/index.js#L4 |
From the dupe issue:
|
Since this is a dupe, closing out. |
reduce unstable conditions caused by such hacking
https://npm.im/deasync
The text was updated successfully, but these errors were encountered: