Skip to content
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

wasm-bindgen-cli panics with "no entry found for key" #4390

Open
sanbox-irl opened this issue Jan 2, 2025 · 3 comments
Open

wasm-bindgen-cli panics with "no entry found for key" #4390

sanbox-irl opened this issue Jan 2, 2025 · 3 comments
Labels

Comments

@sanbox-irl
Copy link

Describe the Bug

A clear and concise description of what the bug is.

Steps to Reproduce

Using a particular WASM file (I've attached it, but I understand that that could be sketchy), wasm-bindgen panics when I run:

wasm-bindgen calm-clamming.wasm --out-dir server

Expected Behavior

I expected it to make the JS glue file.

Actual Behavior

Crashed with:

❯ wasm-bindgen target/wasm32-unknown-unknown/debug/calm-clamming.wasm --out-dir server
thread 'main' panicked at /Users/jjspira/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-bindgen-cli-support-0.2.99/src/wit/mod.rs:481:52:
no entry found for key
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: wasm_bindgen_cli_support::wit::Context::program
   4: wasm_bindgen_cli_support::wit::process
   5: wasm_bindgen_cli_support::Bindgen::generate_output
   6: wasm_bindgen_cli_support::Bindgen::generate
   7: wasm_bindgen::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

calm-clamming.wasm.zip

@sanbox-irl sanbox-irl added the bug label Jan 2, 2025
@daxpedda
Copy link
Collaborator

daxpedda commented Jan 7, 2025

Interesting, its unable to find the main function even though you seem to have marked it with a descriptor. What attributes did you put on your main function and did you compile as a binary or cdylib?

@sanbox-irl
Copy link
Author

@daxpedda appreciate your insight! I had forgotten to pass --lib when compiling it (which I do as a cdylib...I think? I just say --lib and I have ["rlib", "cdylib"] in my Cargo.toml, so I'm not sure what happens there).

Correctly passing lib and using the resulting (calm_clamming_lib.wasm) this error goes away.

Should I close the issue?

To answer your question about the main function, it is:

#[cfg(target_family = "wasm")]
use wasm_bindgen::prelude::*;

#[cfg(target_family = "wasm")]
#[wasm_bindgen(start)]
fn main() -> Result<(), JsValue> {
    real_main().unwrap();

    Ok(())
}

@daxpedda
Copy link
Collaborator

daxpedda commented Jan 8, 2025

I was unable to reproduce this. Would you mind creating a minimal reproducable example in a repo? It would be good if we produce a good error message instead of "no entry found for key".

But glad you solved your problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants