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

WebAssembly.instantiateStreaming does not work with Response #7259

Closed
hazae41 opened this issue Aug 29, 2020 · 8 comments · Fixed by #10158
Closed

WebAssembly.instantiateStreaming does not work with Response #7259

hazae41 opened this issue Aug 29, 2020 · 8 comments · Fixed by #10158
Labels
bug Something isn't working correctly cli related to cli/ dir help wanted community help requested

Comments

@hazae41
Copy link
Contributor

hazae41 commented Aug 29, 2020

hazae41/foras#1

Since Deno 1.3.1, WebAssembly.instanciateStreaming throws the following error when module is an instance of Response (from fetch)

error: Uncaught TypeError: WebAssembly.compile(): Argument 0 must be a buffer source

@lucacasonato
Copy link
Member

@caspervonb do we have a test for this?

@caspervonb
Copy link
Contributor

@caspervonb do we have a test for this?

Hmm, apparently I used a buffer source in the test when I enabled that flag 🤔

@hazae41
Copy link
Contributor Author

hazae41 commented Sep 7, 2020

@caspervonb Do we need to temporarily disable instantiateStreaming? Or implement it with Response?

Because modules using Response are broken since they check for the existence of instantiateStreaming before

if (WebAssembly.instantiateStreaming) {
  // use instantiateStreaming()
} else {
  // get the buffer then use instantiate()
}

@caspervonb
Copy link
Contributor

Because modules using Response are broken since they check for the existence of instantiateStreaming before

Oh right, that's bad.. uhm, I'll get back to you.

@dsherret
Copy link
Member

dsherret commented Oct 8, 2020

I'm able to make this work by doing WebAssembly.instantiateStreaming(response.then(r => r.arrayBuffer()) as any) (which I believe is wrong)

@lucacasonato lucacasonato added the bug Something isn't working correctly label Oct 8, 2020
@bartlomieju bartlomieju added cli related to cli/ dir help wanted community help requested l-rust 🦀 labels Nov 18, 2020
Liamolucko added a commit to Liamolucko/deno that referenced this issue Nov 27, 2020
@ghost
Copy link

ghost commented Jan 2, 2021

Ahh, saw that Deno had WebAssembly.{compileStreaming, instantiateStreaming}, and thought that it would be fun to try to instantiate ~6 wasm files and set up a project. Then some particularly misleading errors appeared :)

In my opinion, If it doesn't work correctly, it should not be exposed at all. Can we get the PR that caused this to be reverted until this is properly sorted out?

@vovacodes
Copy link

Hey folks, is there any progress here? I'd like to use Deno for testing my wasm compiled from Rust with wasm-bindgen but unfortunately, due to this issue Deno chokes on it. I don't control the JS wrapper that calls to WebAssembly.instantiateStreaming (that one is generated by wasm-pack) and even though it does feature detection, that one is broken too (#8968), so it's kinda a blocker.

@lucacasonato
Copy link
Member

Temporary workaround could be to call delete WebAssembly.instantiateStreaming; before instantiating the wasm-pack code.

@ry ry closed this as completed in #10158 Apr 13, 2021
andreubotella pushed a commit to andreubotella/deno that referenced this issue Jul 1, 2021
The WebAssembly streaming APIs used to be enabled, but used to take
buffer sources as their first argument (see denoland#6154 and denoland#7259). This
change reenables it, requiring a Promise<Response> instead.
andreubotella pushed a commit to andreubotella/deno that referenced this issue Jul 3, 2021
The WebAssembly streaming APIs used to be enabled, but used to take
buffer sources as their first argument (see denoland#6154 and denoland#7259). This
change reenables them, requiring a Promise<Response> instead, as well as
enables asynchronous compilation of WebAssembly modules.
lucacasonato pushed a commit that referenced this issue Jul 3, 2021
…ion (#11200)

The WebAssembly streaming APIs used to be enabled, but used to take
buffer sources as their first argument (see #6154 and #7259). This
change re-enables them, requiring a Promise<Response> instead, as well as
enabling asynchronous compilation of WebAssembly modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir help wanted community help requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants