-
Notifications
You must be signed in to change notification settings - Fork 18k
misc/wasm: improve error message when wasm file is not supplied #37000
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
Comments
/cc @neelance |
I think this should be handled in wasmbrowsertest rather than inside the run function. I checked the code and the error paths can be improved to show a better error for cases like these. If you use the node runner, then you don't get an error like this. So I think it falls on wasmbrowsertest to handle this case. |
I saw this before I ever used wasmbrowsertest, when I was messing around with index.html to switch it from clicking a 'Run' button to starting on window load / from the instantiatestreaming callback. I'll have to modify it again when I start messing with service workers in earnest. My point is people who actually use index.html in a real application aren't going to have a run button and will definitely modify index.html's code which calls into wasm_exec.js. Once they do that their index.html is going to start to look nothing like the current index.html. Presumably the plan is for such apps to continue to use wasm_exec.js unmodified to make it easier to take changes from the Go repo. When such apps do so, I think it's reasonable to expect wasm_exec.js to throw exceptions when you use its public APIs incorrectly instead of throwing errors which require devs to read and understand wasm_exec.js's code. |
Please keep in mind that wasm_exec.js's API is not fully "public" until js/wasm is stable. Right now it is meant for early adopters and can change at any time. However, I agree with you that a better error message can ease this pitfall at almost zero cost. I'll add it in the next release cycle. |
Ah yes, that's a good point. |
Change https://golang.org/cl/266117 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried running a WASM binary with wasm_exec.js but didn't properly supply a .wasm file, or perhaps some other error happened. The specifics aren't important - I've seen this error a couple different ways when I did something wrong.
I saw this:
Which was a bit baffling the first time I read it until I poked around.
I want to see this:
wasm instance was not supplied to go.run
or a similar error message.
You can get this effect by modifying wasm_exec.js a bit:
I believe this is the only public function in wasm_exec.js where someone might conceivably run into an error and have no real understanding of how Javascript works since the other functions in wasm_exec.js seem rather low-level.
The text was updated successfully, but these errors were encountered: