-
Notifications
You must be signed in to change notification settings - Fork 18k
syscall/js: running web assembly in Wasmer is failing on bad type flag #40366
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 |
The interface between |
The problem is that syscall/js alone is presuming existence fo Nodejs Wasm constants, and it is doing it during declaration of variables. I can guess that it is current limitation, but could we postpone loading of variables from here:
I tried to prepare minimal reproducible code in repo: https://github.com/martinkunc/gowasmer To reproduce, you can run
and then compare it with
I hope I am not using something which is only intended to work this way. I understand that WASMI is not stable, but maybe it might allow at least run at other runtimes, and I hope the change would be small one. |
The error "bad type flag" is an internal error. It should not even be thrown if something is The constants that you say are missing are in your own code: https://github.com/martinkunc/gowasmer/blob/master/wasm/bridge.go#L169 |
Thank you for the explanation Richard and for pointing to my code and sorry for a confused report. I think I can close the issue. I will try to fix my hack. Btw, thank you for all your hard work on the Wasm support :) |
@martinkunc excuse me! Has this problem beem solved? How to solve it? |
@BruceChoca Unfortunatelly I didn't continued on implementation of fs constants. Instead of what I did was I let my webassembly binary compiled on go 1.13 and built my host binary in latest go. |
@martinkunc thank u !
=>
u can try, hope it will solve your problem. |
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?
I am running Golang WebAssembly in Wasmer. In Go 1.14 the application fails on
panic: bad type flag
, but in Go 1.13 it runs well. The application is importing "syscall/js".What is failing:
I believe it is failing because throwing panic was added in Go 1.14:
https://github.com/golang/go/blob/master/src/syscall/js/js.go#L291
In Go 1.13.9, it by default considers the object type to be js object:
https://github.com/golang/go/blob/go1.13.9/src/syscall/js/js.go#L244
But I believe the real problem is to expect javascript runtime having fs.constants of some type,
which I believe is happening here:
https://github.com/golang/go/blob/master/src/syscall/fs_js.go#L21
Unfortunatelly this syscall variable requires the constant exists before initialization, so I cannot set it before importing "syscall/js"
My humble opinion would be that we could change constants to fsConstants function() {} so that it would be evaluated only when particular fs function would require it (and I would have chance to set it up upfront on another environment).
What did you expect to see?
Application runs fine.
What did you see instead?
Application crashes with:
The text was updated successfully, but these errors were encountered: