Skip to content

fix: catch unhandled RPC rejections from internal API calls - #5636

Merged
svenvoskamp merged 1 commit into
chore/khizr-fixesfrom
chore/khizr-fixes-REOWN-4446
Apr 13, 2026
Merged

fix: catch unhandled RPC rejections from internal API calls#5636
svenvoskamp merged 1 commit into
chore/khizr-fixesfrom
chore/khizr-fixes-REOWN-4446

Conversation

@Khizr97

@Khizr97 Khizr97 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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 await or .catch():

  1. syncAccount() (line 1275) — called in accountChanged event handler. This method internally awaits syncBalance() which makes RPC calls. Since syncAccount() itself isn't awaited, any rejection inside it becomes unhandled.

  2. syncBalance() (line 1282) — called in accountChanged handler for non-active chain path. Direct fire-and-forget RPC call.

  3. syncIdentity() (line 1665) — called at the end of syncAccount(). 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:

  • Prevents unhandled rejections from reaching the consumer
  • Preserves the fire-and-forget behavior (non-blocking)
  • Doesn't change any success path logic
  • Doesn't hide errors from AppKit's own internal error handling (the methods already have try-catch internally for their own logging)

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 await in other paths (e.g., syncBalance is 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

  • 204/204 appkit client tests pass
  • Type check clean
  • Only 3 lines changed (adding .catch(() => null))

Test plan

  • Connect wallet, switch networks — no unhandled rejections in console
  • Simulate RPC failure (e.g., invalid projectId) — errors caught silently, no Sentry noise
  • Balance and ENS still work on success path

🤖 Generated with Claude Code

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>
@linear

linear Bot commented Apr 9, 2026

Copy link
Copy Markdown

@changeset-bot

changeset-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e5743d4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Apr 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
appkit-demo Ready Ready Preview, Comment Apr 9, 2026 11:13pm
appkit-gallery Ready Ready Preview, Comment Apr 9, 2026 11:13pm
appkit-headless-sample-app Ready Ready Preview, Comment Apr 9, 2026 11:13pm
appkit-laboratory Ready Ready Preview, Comment Apr 9, 2026 11:13pm
9 Skipped Deployments
Project Deployment Actions Updated (UTC)
appkit-basic-example Ignored Ignored Apr 9, 2026 11:13pm
appkit-basic-sign-client-example Ignored Ignored Apr 9, 2026 11:13pm
appkit-basic-up-example Ignored Ignored Apr 9, 2026 11:13pm
appkit-ethers5-bera Ignored Ignored Apr 9, 2026 11:13pm
appkit-nansen-demo Ignored Ignored Apr 9, 2026 11:13pm
appkit-wagmi-cdn-example Ignored Ignored Apr 9, 2026 11:13pm
ethereum-provider-wagmi-example Ignored Ignored Apr 9, 2026 11:13pm
next-wagmi-solana-bitcoin-example Ignored Ignored Apr 9, 2026 11:13pm
vue-wagmi-example Ignored Ignored Apr 9, 2026 11:13pm

Request Review

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CTA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Khizr97

Khizr97 commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CTA Document and I hereby sign the CTA

@svenvoskamp
svenvoskamp merged commit b23cf1c into chore/khizr-fixes Apr 13, 2026
17 of 18 checks passed
@svenvoskamp
svenvoskamp deleted the chore/khizr-fixes-REOWN-4446 branch April 13, 2026 16:27
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants