wasm-bindgen
wasm-bindgen copied to clipboard
assertion `left == right` failed
Describe the Bug
#[wasm_bindgen]
pub async fn sha1(
signal: AbortSignal,
blob: Blob,
chunk: Option<i32>,
on_progress: Option<Function>,
) -> Result<String, JsValue> {
let mut hasher = Sha1::new();
wasm_hasher_lib::computed(&signal, blob, chunk, on_progress, &mut hasher).await?;
Ok(format!("{:x}", hasher.finalize()))
}
When I bundle it with webpack and import the module, it will panic
wasm_hasher_sha1_bg.js:286 panicked at /Users/username/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/js-sys-0.3.77/src/lib.rs:6395:1:
assertion `left == right` failed
left: 5000
right: 0
Stack:
Error
at __wbg_new_8a6f238a6ece86ea (webpack-internal:///./packages/cloudoc-sha1/node_modules/@axetroy/wasm-hasher-sha1/wasm_hasher_sha1_bg.js:360:17)
at https://localhost:8080/assets/wasm/_packages_cloudoc-sha1_node_modules_axetroy_wasm-hasher-sha1_wasm_hasher_sha1_bg_wasm.wasm:wasm-function[158]:0x7fb0
at https://localhost:8080/assets/wasm/_packages_cloudoc-sha1_node_modules_axetroy_wasm-hasher-sha1_wasm_hasher_sha1_bg_wasm.wasm:wasm-function[72]:0x6499
at https://localhost:8080/assets/wasm/_packages_cloudoc-sha1_node_modules_axetroy_wasm-hasher-sha1_wasm_hasher_sha1_bg_wasm.wasm:wasm-function[105]:0x77a8
at https://localhost:8080/assets/wasm/_packages_cloudoc-sha1_node_modules_axetroy_wasm-hasher-sha1_wasm_hasher_sha1_bg_wasm.wasm:wasm-function[37]:0x2430
at https://localhost:8080/assets/wasm/_packages_cloudoc-sha1_node_modules_axetroy_wasm-hasher-sha1_wasm_hasher_sha1_bg_wasm.wasm:wasm-function[45]:0x4263
at https://localhost:8080/assets/wasm/_packages_cloudoc-sha1_node_modules_axetroy_wasm-hasher-sha1_wasm_hasher_sha1_bg_wasm.wasm:wasm-function[118]:0x79a0
at __wbg_adapter_22 (webpack-internal:///./packages/cloudoc-sha1/node_modules/@axetroy/wasm-hasher-sha1/wasm_hasher_sha1_bg.js:291:10)
at real (webpack-internal:///./packages/cloudoc-sha1/node_modules/@axetroy/wasm-hasher-sha1/wasm_hasher_sha1_bg.js:194:20)
Steps to Reproduce
[profile.release]
strip = true
then compile with command wasm-pack build --release --target bundler --scope axetroy --out-dir out
Repo: https://github.com/axetroy/wasm-hasher
Expected Behavior
It should not panic
Actual Behavior
Panic in runtime
Additional Context
It works fine in the 2023 version, I'm not sure if it's a rustc issue