-
-
Notifications
You must be signed in to change notification settings - Fork 669
Unexpected behaviour with async/await logic in JS host #812
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
Comments
You try do some continuation (interrupt wasm execution by host code and come back later in the same frame with continue execution). That's not work in WebAssembly without extra efforts. See this experimental PR which describe pretty simple example usage of Binaryen's Asyncify. But this required latest Binaryen which not yet landed |
Thanks, I'll try that out! Is there any other way of achieving a callback function, given that the Table is removed? |
You could use table. Just add |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm building a WASM application that relies upon external, asynchronous operations carried out by the host. The WASM part must initiate an unknown number of requests by means of a function call to the host, and then await responses.
Awaiting promises is causing an issue, where the first value is always ignored
Context
I have this WASM code:
Correspondingly,
operation.call()
is provided in the Node.js application using the loader:Expected results
When
myOperation()
is called on the WASM, it should calloperation.call()
and get some value back. The first call is always a zero value, which is never returned by the promise in this case. Subsequent calls produce the previous value.To try to understand what's happened, I've included some
console.log()
statements. I expected them to the called in numeric order, but they're not. The output to the console is:Any idea why this might be?
Additionally, since function callback references and the table seem to have been disabled, is there any better way to get asynchronous data from the WASM host on demand?
The text was updated successfully, but these errors were encountered: