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

WASI initialization in child thread #4102

Closed
toyobayashi opened this issue Feb 16, 2023 · 3 comments
Closed

WASI initialization in child thread #4102

toyobayashi opened this issue Feb 16, 2023 · 3 comments

Comments

@toyobayashi
Copy link

toyobayashi commented Feb 16, 2023

Details

wasi requires calling initialize() or start() after instantiating wasm and requires that memory is exported from wasm, but this doesn't work in multithreaded scenario (wasm32-wasi-threads target).

With wasi threads, we need to provide wasm memory created in JavaScript (new WebAssembly.Memory({ shared: true })) in main thread, and send the memory to child thread to instantiate wasm again in child thread, and it is unnecessary (and will cause error) to call initialize() or start() in child thread. So normal usage of WASI doesn't work in child thread. But we still need an "initialized" WASI instance in child thread.

Currently I'm using cloned instance object and Proxy to workaround this problem. Is there any possibility to handle this in future Node.js API change?

Node.js version

18.14.0

Example code

https://github.com/toyobayashi/emnapi/blob/9bc69c52bc8d582c92acc754ea6a0050572d871b/packages/core/src/load.js

loadNapiModuleImpl

Operating system

macOS 13.2

Scope

code? or runtime?

Module and version

require('node:wasi').WASI

@preveen-stack
Copy link
Contributor

cc @nodejs/wasi

Copy link

github-actions bot commented May 7, 2024

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment.
If you need further assistance or have questions, you can also search for similar issues on Stack Overflow.
Make sure to look at the README file for the most updated links.

@github-actions github-actions bot added the stale label May 7, 2024
Copy link

github-actions bot commented Jun 7, 2024

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment.
If you need further assistance or have questions, you can also search for similar issues on Stack Overflow.
Make sure to look at the README file for the most updated links.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants