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

assertion left == right failed #4444

Open
axetroy opened this issue Feb 28, 2025 · 0 comments
Open

assertion left == right failed #4444

axetroy opened this issue Feb 28, 2025 · 0 comments
Labels

Comments

@axetroy
Copy link

axetroy commented Feb 28, 2025

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

@axetroy axetroy added the bug label Feb 28, 2025
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

1 participant