fix(maticjs): surface the real cause of ABI/network metadata fetch failures - #477
Merged
Merged
Conversation
MaximusHaximus
force-pushed
the
worktree-maticjs-error-visibility
branch
from
June 26, 2026 12:13
c495b43 to
8631e39
Compare
…ilures ABIManager.init resolves network metadata over HTTP; the fetch did a bare res.json() with no status check, and Web3SideChainClient.init then discarded whatever it threw and rethrew a generic "network <x> - <v> is not supported". Any transport/CDN problem (non-2xx, HTML error/challenge page, timeout) was therefore undiagnosable. HttpRequest now checks res.ok and reports the HTTP status + a body snippet (and flags non-JSON bodies); init preserves the underlying error in the message and as `cause`. Adds tests covering non-2xx, non-JSON-2xx, and the happy path. No behavioural change on success.
MaximusHaximus
force-pushed
the
worktree-maticjs-error-visibility
branch
from
June 26, 2026 12:17
8631e39 to
2dc5cc7
Compare
MaximusHaximus
marked this pull request as ready for review
June 26, 2026 12:18
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
shan8851
approved these changes
Jun 26, 2026
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.
Problem
ABIManager.init()resolves network metadata by GETting<abiStoreUrl>/<network>/<version>/index.json. Two layers conspired to make any failure there undiagnosable:HttpRequest.getdid a bareres.json()with no status check (src/utils/http_request.ts). A non-2xx response — e.g. a CDN/WAF403/429, or an HTML error/challenge page served with a200— maderes.json()throw a context-freeUnexpected token <, losing the status entirely.Web3SideChainClient.initdiscarded that error (src/utils/web3_side_chain_client.ts):abiManager.init().catch(() => { throw new Error(\network ${network} - ${version} is not supported`) })`. The real cause was thrown away and replaced with a generic "not supported".Net effect: a transport/CDN problem (throttling, edge error page, timeout, DNS) surfaces as
network mainnet - v1 is not supportedwith no way to tell what actually went wrong. We hit this in downstream e2e CI — the manifest fetch fails intermittently from shared CI egress IPs, and the masked error gave us nothing to act on.Fix
HttpRequestnow checksres.okand throwsHTTP <status> <statusText> for <method> <url>: <body snippet>on a non-2xx, and on a 2xx-but-non-JSON body throwsExpected JSON ... (content-type: ...) but parsing failed: <snippet>. Shared helper used by bothgetandpost.Web3SideChainClient.initpreserves the underlying error — both inlined in the message (... is not supported: <reason>) and as the error'scause— instead of discarding it.No behavioural change on the success path.
Tests
tests/http-request-error-visibility.test.ts(3 cases, local HTTP server): non-2xx surfaces status + body; non-JSON 2xx is reported with content-type + snippet; valid JSON still parses. Full package suite: 29 passed. Typecheck + webpack build green.