Skip to content

Fails to compile with "no function table found in module" #1967

Closed
@hexpunk

Description

@hexpunk

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.

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