web-rwkv-wasm: surface the full error chain across the JS boundary#64
Open
sebastian-zm wants to merge 1 commit into
Open
web-rwkv-wasm: surface the full error chain across the JS boundary#64sebastian-zm wants to merge 1 commit into
sebastian-zm wants to merge 1 commit into
Conversation
The session bindings collapsed every failure to its top-level message
(`JsError::new(&err.to_string())`). For inference errors that meant JS only
ever saw `RuntimeError`'s `Display` — the literal string `"tensor error"` —
which hides the inner `TensorError` (e.g. `tensor shape not match: ...`) that
actually explains the failure. Debugging a failing model from the browser was
effectively impossible.
Format errors with `{:?}` so `anyhow::Error`'s full "Caused by:" chain reaches
JS, and route the ad-hoc buffer-length validation messages through
`anyhow::anyhow!` so they keep flowing through the same helper.
No API change; only the text of thrown errors becomes more informative.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Quick follow-up to #62 — a small DX fix to the wasm crate I just added there. Sorry for the
immediate second PR on the same code.
Summary
The
err()helper that converts Rust errors intoJsErrorformatted them withDisplay({}). For the runtime's top-level error type thatDisplayimpl isjust the string
"tensor error", so every failure crossing the JS boundarycollapsed to that one useless message — the actual cause (shape mismatch,
missing tensor, etc.) was dropped.
This switches
err()to format with{:?}, which preserves the fullanyhowcause chain, and takesimpl Into<anyhow::Error>so call sites buildad-hoc messages with
anyhow::anyhow!(...).Before / after
Loading a model whose tensors don't line up, as seen from JS:
Same failure, but now it's actually diagnosable without a Rust-side debug build.
Scope
crates/web-rwkv-wasm/src/session.rs), no API/behavior change on thesuccess path — only the text of the
Errorthrown to JS.format!(...)string now passanyhow::anyhow!(...)so they satisfy theInto<anyhow::Error>bound.