-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
JS InstantiateStreaming fallback does not work #1696
Comments
Thanks for the report! The bug here is actually unrelated to appliation/wasm mime types but there's a real instantiation error which happens regardless. I do think though that there's a bug in our instantiation fallback in the sense that this is a pretty confusing error message and we should probably get the original error to get displayed. @fitzgen would you be able to take a look at this? |
I've definitely had the fallback work for me (eg with |
Well, we do get the original error displayed, in this case it is
So it looks like we are generating an import, but then the isntantiation code is buggy? |
Oh sorry yeah what I mean is that the instantiation fallback definitely works for the mime type, but it's aggressively retrying all errors as opposed to just errors related to the mime type. We should ideally only handle errors related to mime type and otherwise propagate all other errors. (this is all sort of independent of whether there's a wasm-bindgen bug as well) |
This is kind of a philosophical question. We don't have a dedicated
Do we want to play the (3) game? Do the benefits outweigh the costs in this situation? |
I do sort of think we want to play the (3) game a little bit because I've been pretty confused by this before. Our fallback reports the wrong error in the JS console since the body is already consumed if the instantiation fails for any reason other than headers not working well. Could we perhaps do something like:
That way we're not really doing error detection per se, but we are only whitelisting one case for continuing with the fallback. Similarly we could try to call |
This commit improves our `instantiateStreaming` fallback to only actually trigger the fallback if the headers look wrong. If the headers look right then we let through the original error which should help avoid accidentally papering over bugs with different bugs in misconfigured situations. Closes rustwasm#1696
Describe the Bug
In the generated JS file there's a fallback for when
InstantiateStreaming
doesn't work. This code will never succeed because thefetch
body has already been consumed:wasm-bindgen/crates/cli-support/src/js/mod.rs
Lines 538 to 546 in 732b691
Steps to Reproduce
I've got a bad wasm setup right now, and not sure why it's bad (I do have the mime set to
application/wasm
, but yeah, not sure what's going on).Expected Behavior
The fallback should be working.
Actual Behavior
The fallback breaks because the request body is already consumed. Not working on both Chrome and Firefox.
chrome
firefox
Additional Context
I think the way to fix it is by sending out another
fetch
request. It's wasteful, but it's probably better than straight up throwing.Also I should figure out how to make streaming work from my server, but that's on me, haha. Thanks!
The text was updated successfully, but these errors were encountered: