Skip to content

WASI initialization in child thread #4102

Closed as not planned
Closed as not planned

Description

@toyobayashi

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

Activity

  1. preveen-stack commented on Aug 25, 2023

    @preveen-stack
    Contributor

    cc @nodejs/wasi

  2. github-actions commented on May 7, 2024

    @github-actions

    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.

  3. github-actions commented on Jun 7, 2024

    @github-actions

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions