Skip to content

TypeError: WebAssembly.instantiate(): Imports argument must be present and must be an object #4399

Closed
@UebelAndre

Description

@UebelAndre

Describe the Bug

I was working on bazelbuild/rules_rust#3174 and noticed when I bumped wasm-bindgen from 0.2.93 to 0.2.95 I started seeing:

[TypeError: WebAssembly.instantiate(): Imports argument must be present and must be an object]

I know Bazel is not a consideration for this repo but I'm still hoping someone could shed some light on why I might be seeing this issue on 0.2.95. I'm currently trying to bump to 0.2.99 and see the same failure there.

I've tried using the following diff and all it did was change the error slightly

diff --git a/extensions/wasm_bindgen/rules_js/test/hello_world_wasm_test.js b/extensions/wasm_bindgen/rules_js/test/hello_world_wasm_test.js
index 61fc3839..f8dbfdbb 100644
--- a/extensions/wasm_bindgen/rules_js/test/hello_world_wasm_test.js
+++ b/extensions/wasm_bindgen/rules_js/test/hello_world_wasm_test.js
@@ -15,7 +15,7 @@ const main = async function (typ, dir) {
     const buf = fs.readFileSync(wasm_file);
     assert.ok(buf);

-    const res = await WebAssembly.instantiate(buf);
+    const res = await WebAssembly.instantiate(buf, {});
     assert.ok(res);
     assert.strictEqual(res.instance.exports.double(2), 4);
 };
[TypeError: WebAssembly.instantiate(): Import #0 module="wbg" error: module is not an object or function]

A clear and concise description of what the bug is.

Steps to Reproduce

I do not have a repro outside of Bazel but with bazelbuild/rules_rust#3174 the error can be reproduced:

  • navigate to extensions/wasm_bindgen
  • run bazel test //...

Expected Behavior

There should be no error caused by the test.

Actual Behavior

The test should pass as it used to on 0.2.93.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions