fix: catch unhandled RPC rejections from internal API calls - #5636
Merged
Conversation
Internal RPC calls (balance sync, ENS identity resolution) through rpc.walletconnect.org are intentionally fire-and-forget but lacked .catch() handlers. When the Ankr backend returns errors (rate limits, unauthorized), these propagated as unhandled promise rejections to the consumer app, polluting Sentry and browser console. Added .catch(() => null) on three fire-and-forget call sites: - syncAccount() in accountChanged handler - syncBalance() in accountChanged handler (non-active chain path) - syncIdentity() in syncAccount method Closes REOWN-4446 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
Contributor
|
All contributors have signed the CTA ✍️ ✅ |
svenvoskamp
approved these changes
Apr 13, 2026
Contributor
Author
|
I have read the CTA Document and I hereby sign the CTA |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Prevents Ankr "Unauthorized" and other RPC errors from rpc.walletconnect.org from bubbling up as unhandled promise rejections to consumer apps (REOWN-4446).
Technical Report
Problem
Internal RPC calls (balance sync, ENS identity resolution) through rpc.walletconnect.org sometimes fail when the Ankr backend rate-limits or returns "Unauthorized". These errors surface as unhandled promise rejections, polluting consumer apps' Sentry and browser console. Reported as ~15 events over 2 days in production.
Root Cause Analysis
Three async call sites in appkit-base-client.ts were fire-and-forget — async functions called without
awaitor.catch():syncAccount()(line 1275) — called inaccountChangedevent handler. This method internally awaitssyncBalance()which makes RPC calls. SincesyncAccount()itself isn't awaited, any rejection inside it becomes unhandled.syncBalance()(line 1282) — called inaccountChangedhandler for non-active chain path. Direct fire-and-forget RPC call.syncIdentity()(line 1665) — called at the end ofsyncAccount(). Makes ENS resolution calls through the blockchain API.These calls are intentionally not awaited — they're background sync operations that shouldn't block the connection flow. But without
.catch(), their rejections escape to the global unhandled rejection handler.Approach & Reasoning
Added
.catch(() => null)on all three fire-and-forget call sites. This is the minimal fix that:Why
.catch(() => null)and not.catch(console.warn): These errors are already logged internally where they originate (e.g., syncBalance catches and logs its own failures). Adding another console.warn at the call site would duplicate the log. Silent catch is correct here — it just prevents the rejection from being "unhandled".Why not add try-catch inside the methods instead: The methods are also called with
awaitin other paths (e.g.,syncBalanceis awaited on lines 1660-1662). Adding internal catch-all would swallow errors for callers that DO want to handle them. The fix correctly targets only the fire-and-forget call sites.Verification
.catch(() => null))Test plan
🤖 Generated with Claude Code