Skip to content
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

Promises do not work (WebAssembly.instantiate in particular) #46

Open
alexdoesh opened this issue May 27, 2022 · 2 comments
Open

Promises do not work (WebAssembly.instantiate in particular) #46

alexdoesh opened this issue May 27, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@alexdoesh
Copy link

Looks like WebAssembly.instantiate(...).then(...).catch(...) can't be properly evaluated due to lack of microtasks processing and message pumping in eval methods. I see a bunch of examples how to implement this in the old v8 versions, but can't understand yet what to do in 10.x, the API was changed significantly. Any chance you can advice how to proceed?

@alexdoesh
Copy link
Author

I "brute forced" a solution for my case -> #47 + a wrapper like this:

context.eval("""
var instance = null;
WebAssembly.instantiate(moduleRaw, {}).then(result => {
    instance = result.instance;
}).catch(result => {
    instance = result.message;
});""")
while context.eval('instance === null'):  # covered with timeout in production
    pass

@buffer
Copy link
Collaborator

buffer commented May 27, 2022

Thanks!

The approach looks really interesting and it is definitely worth exploring. I enabled the tests for your PR and it seems like your code is passing all the existing ones. I think that creating some additional unit tests that focus just on your patch is probably another useful step we should consider. Once we have that in place I will take care of performing an additional check running Thug [1] unit test suite using your branch. This unit test suite is way more extensive than the STPyV8 one and could help spotting potential issues if any.

[1] https://github.com/buffer/thug

@buffer buffer self-assigned this Aug 9, 2022
@buffer buffer added the enhancement New feature or request label Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants