Open ghost opened 4 years ago
Maybe before creating the Promise, there should be a test is it is async function.
function isAsync(func) {
return func.constructor.name === "AsyncFunction";
}
Late to the party here, but I solved this problem using sync-rpc to put my asynchronous operations into a worker thread. It's like magic! The main thread sees synchronous operation while the worker thread does the async stuff. Sounds complicated (for someone like me who never used workers before) but just follow the example in sync-rpc and it's not very difficult.
I tried to write a script runner, but it does not wait for async functions:
Tried that too, but it exits instantly:
Any ideas?