Skip to content

Consider using compileStreaming and instantiateStreaming to enable WASM caching on Node #363

Closed
@landonxjames

Description

@landonxjames

According to this V8 blog post (which is from 2019 so might be out of date, but I couldn't find anything newer), WASM modules are only cached when using the compileStreaming and instantiateStreaming APIs. Both of these are supported by Node (implementation PR). Although MDN says Node doesn't support compileStreaming, I have tested it and it exists and works as expected. Switching to these, and ideally just using instantiateStreaming seems like it could provide substantial performance improvements in cases where users need multiple instances of the same module, or by allowing for the instantiation of modules in Worker threads.

The *Streaming APIs expect the Response type return of a fetch call, unfortunately Node's fetch doesn't seem to support getting local files yet. Thankfully it is possible to manually construct a Response object with a Content-Type: application/wasm header that is accepted by the APIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions