Closed redoC-A2k closed 4 days ago
Hi! Is this a question about WASM, or async promises?
About async promises
The key thing about promises is that they aren't synchronous, so I'm not understanding what your trying to achieve
Did that answer your question, @redoC-A2k?
Node.js Version
20
NPM Version
10
Operating System
linux
Subsystem
async_hooks, v8, Other
Description
I want to resolve promise synchronously in nodejs anyhow . Please help me . Acutally the reason is I want to call async functions from another environment (wasm) (that environment is a trait implemented ) .
From that environment once I call any async function it returns promise . And the only way to resolve promise is to call "then" on it but then always takes callback and till that callback resolves the synchronous function in rust completes ( I can't block thread on wasm environment since it is again single threaded if I do so it gets blocked permanently) And if I do following
When I call above function from wasm , then again fn function returns "something" and execution proceeds as the then callback will not execute instantaneously . It has been 7-10 days due to how difficult it is to resolve promise synchronously in nodejs . Please help me even If I need to use nodejs addon api I am fine with that but I want a way to run promise synchronously anyhow . I have used library like deasync but it did not worked , further other library like await-sync ( using worker threads ) come with limitation that async function can't access surrounding scope . If I use a library like sync-rpc (which instantiate another node process I think) then it has limitation that it needs a whole different file in cjs syntax .
Minimal Reproduction
No response
Output
No response
Before You Submit