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

Setting panic hook in initialization function causes wasm-pack to break #26

Open
ThatNerdUKnow opened this issue Mar 25, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ThatNerdUKnow
Copy link

ThatNerdUKnow commented Mar 25, 2023

Describe the Bug

I'm defining my initalization function like so:

#[wasm_bindgen]
pub fn init() {
    #[cfg(feature = "console_error_panic_hook")]
    panic::set_hook(Box::new(console_error_panic_hook::hook));

    //set_panic_hook();
    wasm_logger::init(wasm_logger::Config::default());
}

This gives the following error when running wasm-pack build --release

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"Error"`,
 right: `"Error2"`', crates\cli-support\src\js\mod.rs:175:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Running the wasm-bindgen CLI
Caused by: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 101
  full command: "C:\\Users\\brand\\AppData\\Local\\.wasm-pack\\wasm-bindgen-7e757a9923d43b8a\\wasm-bindgen.exe" "C:\\Users\\brand\\repos\\celeste\\satellite-rs\\target\\wasm32-unknown-unknown\\release\\satellite_rs.wasm" "--out-dir" "C:\\Users\\brand\\repos\\celeste\\satellite-rs\\pkg" "--typescript" "--target" "bundler"

this error does not occur if I disable the "console_error_panic_hook" feature

Steps to Reproduce

  1. See error

Expected Behavior

I would expect that I would be able to create a wasm-bindgen function that I can call from my frontend to initalize the logging hook

Actual Behavior

Got the following error on wasm-pack build:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"Error"`,
 right: `"Error2"`', crates\cli-support\src\js\mod.rs:175:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Running the wasm-bindgen CLI
Caused by: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 101
  full command: "C:\\Users\\brand\\AppData\\Local\\.wasm-pack\\wasm-bindgen-7e757a9923d43b8a\\wasm-bindgen.exe" "C:\\Users\\brand\\repos\\celeste\\satellite-rs\\target\\wasm32-unknown-unknown\\release\\satellite_rs.wasm" "--out-dir" "C:\\Users\\brand\\repos\\celeste\\satellite-rs\\pkg" "--typescript" "--target" "bundler"
@ThatNerdUKnow ThatNerdUKnow added the bug Something isn't working label Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant