Wasm-bindgen: Fails to compile with "no function table found in module"

Created on 21 Jan 2020  路  2Comments  路  Source: rustwasm/wasm-bindgen

Describe the Bug

Could not compile due to error:

error: failed to generate bindings for import of `__wbindgen_placeholder__::__wbindgen_closure_wrapper28`

Caused by:
    no function table found in module
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 1

Steps to Reproduce

Use the following code in lib.rs, which the compiler says is correct:

use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::console::{log_1, profile_0, profile_end_0};
use web_sys::window;

#[wasm_bindgen(start)]
pub fn run() {
    let win = window().expect("no global `window` exists");

    profile_0();

    log_1(&"Hello from Rust!".into());

    let cb = Closure::wrap(Box::new(profile_end_0) as Box<dyn Fn()>);

    win.set_timeout_with_callback_and_timeout_and_arguments_0(cb.as_ref().unchecked_ref(), 5)
        .expect("could not set timeout");

    cb.forget();
}

Try to compile by running wasm-pack build with any combination of options.

Expected Behavior

Compile and run without issue.

Actual Behavior

Receive the error message:

error: failed to generate bindings for import of `__wbindgen_placeholder__::__wbindgen_closure_wrapper28`

Caused by:
    no function table found in module
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 1

Additional Context

I'm using wasm-bindgen 0.2.58 and web-sys 0.3.35.

bug

Most helpful comment

Thanks for the report! Looks like this was an internal mistake and should be fixed in https://github.com/rustwasm/wasm-bindgen/pull/1970

All 2 comments

This appears to be a regression as this occurs in versions 0.2.58, 0.2.57, and 0.2.56, but not in 0.2.55. That version appears to work just fine.

Thanks for the report! Looks like this was an internal mistake and should be fixed in https://github.com/rustwasm/wasm-bindgen/pull/1970

Was this page helpful?
0 / 5 - 0 ratings