fix(tng-wasm): clean up browser fetch-failure error logging#166
Merged
Conversation
wasm-unit-test now simply delegates to wasm-unit-test-chrome, removing the duplicated nightly wasm-pack test line that ran alongside it.
Downgrading wasm-bindgen-test (and the matching wasm-bindgen / web-sys / js-sys / wasm-bindgen-futures versions in Cargo.lock) to 0.3.50 fixes "no tests to run!" reported by `make wasm-unit-test-firefox`. Pin the dev-dependency with `=0.3.50` so it no longer floats up to the broken 0.3.45/+nightly combination.
Bumps the patched reqwest to rev 472703bfd5d3eb415bece730230a823e07dabb78, which improves the Display formatting of js_sys::Error surfaced from wasm fetch failures.
… test Firefox surfaces 'TypeError: NetworkError when attempting to fetch resource.' instead of 'TypeError: Failed to fetch', so the render-cleanliness test skipped the message-count and browser-opacity-hint assertions when the Firefox wording is detected.
Collaborator
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
Collaborator
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Summary
Browser fetch failures in the wasm SDK (e.g. when the Attestation Service is unreachable) produced an opaque, duplicated error with no indication of what failed or why the reason is hidden:
Two problems:
TypeError: Failed to fetchwas duplicated and wrapped in a rawJsValue(...).What changed
reqwest fork (rev
edd4658→472703b) —chore(deps): bump reqwest rev for cleaner wasm js_sys::Error printingRewrites the wasm-only
crate::error::wasm()so a fetch rejection renders<name>: <message>once and the.stackonce — noJsValue(...)wrapper, no duplication. On V8/Chrome theError.stackitself begins with the<name>: <message>line, so the stack is used verbatim when it already starts with the head (instead of prepending it again). For fetch failures it appends aNote:explaining that browsers do not expose the underlying reason and listing common causes (server unreachable, mixed-content, CORS, TLS). Non-Errorrejections fall back to the previousDebugrendering.In-repo URL/method context —
tng: attach URL/method context to AS fetch failurespub fn as_addr()accessor chain across the converter types (CocoRestfulConverter/CocoGrpcConverter/BuiltinCocoConverter/ItaConverter→CocoConverter→TngConverter), mirroring the existingget_nonce/convertdispatch.Builtinreturns a&'static strsentinel (no remote AS address). TheBuiltinarm is#[cfg(feature = "__builtin-as")]-gated to match the variant. This is additive-only on the publishedrats-certcrate — therats-cert::Errorenum is untouched..with_context(|| format!(...))at the two AS fetch sites intng/.../security/client.rs(the/challengeget_noncecall and the key-config POST) so the failing address surfaces in the error chain, preserving the source chain (no stringification).Test + harness —
test(tng-wasm): assert clean rendering of browser fetch failures,fix(tng-wasm): pin wasm-bindgen-test ...,test(tng-wasm): handle firefox-specific fetch error message ...tng-wasm/tests/fetch_error.rs: awasm_bindgen_testthat fetches an invalid host and asserts the rendered rejection has noJsValue(wrapper, exactly oneTypeError: Failed to fetch, and contains theNote:hint (Chrome). Firefox surfaces a different message (NetworkError when attempting to fetch resource.), so the message-count/Note assertions are skipped on Firefox; the no-JsValue(-wrapper check runs on both.wasm-bindgen-test = "=0.3.50"(and the matching wasm-bindgen/web-sys/js-sys/wasm-bindgen-futures versions inCargo.lock) to fix thewasm-pack"no tests to run!" harness issue, so the wasm tests actually execute.chore(wasm): drop redundant wasm-unit-test invocation—wasm-unit-testnow just delegates towasm-unit-test-chrome.Resulting error chain (Chrome)
Compatibility
Additive-only: new
pubaccessor methods onrats-certconverter types; no endpoint, config field, or public struct/field removed or renamed. Thewasm-bindgen-testpin is a dev-dependency change. Nodocs/version_compatibility.mdrow needed.Checklist
cargo fmt,cargo check -p tng -p rats-cert,make clippycleanmake wasm-unit-test-chrome/-firefoxafter the harness pin fixCo-Authored-Bytrailers, gpgsig, or AI attribution in any committng-wasm/www/) wasm bundle rebuilt against the new reqwest rev for deployment (bundle is gitignored; built separately on deploy)