fix(frontend): fail over between RPC endpoints and surface event load errors - #557
Open
masusanou wants to merge 1 commit into
Open
fix(frontend): fail over between RPC endpoints and surface event load errors#557masusanou wants to merge 1 commit into
masusanou wants to merge 1 commit into
Conversation
… errors A dead NEXT_PUBLIC_PROVIDER_RPC endpoint takes every on-chain read down with it, and /events renders the failure as an empty list with no message. - add rpcProviders with a prioritized endpoint list, per-endpoint chain validation, and failover for transport or endpoint-availability failures - preserve semantic contract errors instead of masking them with fallback data - read contracts in contractMethods through that provider - build activeChain rpc from the same list so a missing env var no longer puts undefined at the head of the list - return record and count errors from useEvents, guard stale requests, and show load failures on /events ethers' FallbackProvider does not cover the inactive-endpoint case once ethers maps it to CALL_EXCEPTION. Retrying at the raw JSON-RPC send layer preserves semantic reverts while allowing recognized availability failures to move to the next validated endpoint. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@geeknees is attempting to deploy a commit to the Maboroshi's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
NEXT_PUBLIC_PROVIDER_RPC, comma-separatedNEXT_PUBLIC_PROVIDER_RPC_FALLBACKS, then the RPC derived from the existing thirdweb client ID.NEXT_PUBLIC_CHAIN_ID, then retry ethers-based reads only for transport, authentication, rate-limit, and recognized endpoint-availability failures.activeChain.rpcwithout placing an undefined environment value first.useEvents, ignore stale async completions, and show a localized error on/eventsinstead of rendering an indistinguishable empty list.Incident context
The production Polygon RPC currently responds with HTTP 403 and
App is inactive. Reading the deployed EventManager through another Polygon RPC returnsgetEventRecordCount() = 1070, so the on-chain data remains intact and the failure is in the read path.Important scope limitation
The
/eventsreads themselves go through thirdweb SDK v3. That SDK selects the first entry inactiveChain.rpc; it does not perform runtime failover across the array. Therefore this PR makes the outage visible on/events, provides runtime failover for the ethers-based reads incontractMethods.ts, and allows thirdweb to use the derived RPC whenNEXT_PUBLIC_PROVIDER_RPCis missing. It does not make thirdweb/eventsreads fail over when a configured first endpoint is unhealthy.Restoring production still requires replacing/reactivating
NEXT_PUBLIC_PROVIDER_RPCand rebuilding/redeploying the frontend.Validation
yarn tsc --noEmit— passyarn next lint --dir src— pass, no warnings or errorsyarn build— pass; optimized production build compiled and generated all 33 static pages (the env-less verification worktree emitted expected thirdweb clientId warnings)contractMethods.tsis already Prettier-noncompliant onstaging; this PR deliberately avoids unrelated whole-file formattinggit diff --check HEAD~1 HEAD— passrpcProviders.ts:137.rpc.thirdweb.com; deployed EventManagergetEventRecordCount()returns10701is rejected whenNEXT_PUBLIC_CHAIN_ID=137execution revertedresponse is preserved asCALL_EXCEPTION, with zero calls to the fallback endpointNo RPC endpoint is configured. Set NEXT_PUBLIC_PROVIDER_RPC.The
/eventserror state has not been manually verified in a browser.Failover semantics
Chain checks are cached only after successful validation. Availability failures move to the next endpoint, while semantic RPC failures are returned immediately to the caller.
Closes #556