Support for async / await
munjalpatel opened this issue · comments
What is your question?
Is it possible to use async/await in JS that will be compiled to wasm using Javy?
Hello @munjalpatel,
Not sure about your use case, but I could use async/await
in my JS runtime based on Javy. The key methods are is_pending
and execute_pending
. They allow you to run any async method that it's waiting.
From the Javy / core crate, the run_bytecode_inner
runs pending items. You only need to enable the experimental_event_loop
feature:
javy/crates/core/src/execution.rs
Lines 11 to 20 in cdd9d66
If your use case is related to using Javy
as a library to create your own JS runtime, you can use those methods to ensure QuickJS processes the async methods. I recently added this feature to a project I'm working on. You can find the code in this PR: vmware-labs/wasm-workers-server#143.
As mentioned in #386, the CLI does not currently support network requests or the fetch API.
As @Angelmmiguel mentions, you can use the library crates in Javy to create your own runtime that you compile to a Wasm module and build your own CLI around that module.
Closing this for now. Feel free to comment if you feel that your question has not been answered.