-
-
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
Externref/Reference types throwing error in Node #2274
Comments
Thanks for the report! I think this is because node hasn't updated to the latest version of reference types, so we'll need to wait for them to update v8. |
Thanks for clarifying! |
Here is the PR, which will update Node v8 to 8.5: |
Thanks for the pointer, looks like things should work as expected once that propagates! |
Node 15 will ship with v8 8.6, so I'll give this another try |
Confirming that it now works with Node 15 and v8 8.6 |
Unfortunately, I now got another error with Node 15.4.0 and wasm-bindgen 0.2.69 with a more advanced example and reference types enabled. The error looks a bit different: const wasmModule = new WebAssembly.Module(bytes);
^
CompileError: WebAssembly.Module(): Compiling function #99:"__externref_table_alloc" failed: local.tee[0] expected type i32, found ref.null of type externref @+39165 The generated JS code at that position calling the function addToExternrefTable0(obj) {
const idx = wasm.__externref_table_alloc();
wasm.__wbindgen_export_2.set(idx, obj);
return idx;
} I hope this information is enough since I'm not sure what causes the issue and my code is not yet ready for being released publicly. |
Hm that may be a mismatch in node's expected encoding of a wasm module and what Rust is doing? I forget the precise verisons at which everything starts to align. |
I’m gonna retry this once v8 8.7 lands in Nodejs with this PR: |
So I tried out the Nodejs version of this specific PR with v8 8.7, but I get the same error. |
I wanted to open an issue in the Nodejs repository, if anyone has an idea and I wanted to send there the relevant code as However I get a similar error: ❯ ../wabt/build/wasm2wat ./pkg/server_bg.wasm --enable-all
./pkg/server_bg.wasm:0009901: error: type mismatch in local.tee, expected [i32] but got [... externref]
./pkg/server_bg.wasm:0009904: error: type mismatch in table.grow, expected [externref, i32] but got [i32, i32]
./pkg/server_bg.wasm:0009a8d: error: type mismatch in function, expected [] but got [i32, i32]
./pkg/server_bg.wasm:0009da3: error: type mismatch in function, expected [] but got [i32]
./pkg/server_bg.wasm:000ac58: error: type mismatch in function, expected [] but got [i32, i32, i32] @alexcrichton do you still think this is an issue from the specs not yet being aligned? |
Unfortunately I'm not entirely sure. If other runtimes accept the same wasm file then it seems like this is node-specific though? |
I quadruple checked this again and it definitely seems as if the generated wasm code works in Chrome and FF. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>My awesome Rust, WebAssembly, and Webpack application</title>
</head>
<body>
<div id="root"></div>
<script>
import("./index.js").then((m) => {
console.log("wasm", m);
});
</script>
</body>
</html> I get other awesome errors with Webpack with ERROR in .../pkg/index_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value |
It may be that webpack's wasm parser doesn't support the reference types proposal perhaps? But otherwise if browsers accept the wasm module then it seems like it may be an issue on node's end? I would have to dig in more to be certain though. |
I just wanted to confirm, that updating wasm-bindgen from 0.2.70 to 0.2.74 fixed the issue. |
Building with
--reference-types --target nodejs
and importing the result in Node results in the following error:Repository
Tested with Node 14.17.0 and 12.18.3
Interestingly this bug doesn't happen with Deno.
Is this bug related to Node, v8 or wasm-bindgen?
Node 14.17.0 uses v8 8.4.371.19-node.12 and Deno 1.2.2 uses v8 8.5.216
The text was updated successfully, but these errors were encountered: