Skip to content

Fix/set wcerror#5548

Merged
tomiir merged 10 commits intomainfrom
fix/set-wcerror
Feb 18, 2026
Merged

Fix/set wcerror#5548
tomiir merged 10 commits intomainfrom
fix/set-wcerror

Conversation

@tomiir
Copy link
Collaborator

@tomiir tomiir commented Feb 18, 2026

Description

  • Handles WC Errors on mobile connections and sets wcError flag

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Copilot AI review requested due to automatic review settings February 18, 2026 08:28
@vercel
Copy link

vercel bot commented Feb 18, 2026

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

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

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: 9323651

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@reown/appkit-controllers Patch
@reown/appkit Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-ton Patch
@reown/appkit-adapter-tron Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-ui Patch
@reown/appkit-core Patch
@reown/appkit-utils Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet-button Patch
@reown/appkit-experimental Patch
@reown/appkit-pay Patch
@reown/appkit-universal-connector Patch
@reown/appkit-cdn Patch
@reown/appkit-testing Patch
@reown/appkit-common Patch
@reown/appkit-polyfills Patch
@reown/appkit-wallet Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

Visual Regression Test Results ✅ Passed

⚠️ 15 visual change(s) detected

Chromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=779
Storybook Preview: https://6493191bf4b10fed8ca7353f-sbeherazlb.chromatic.com/

👉 Please review the visual changes in Chromatic and accept or reject them.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where mobile WalletConnect connections that fail would not properly set the wcError flag, leaving the application in an inconsistent state. The fix adds a catch handler to capture connection failures and update the error state accordingly.

Changes:

  • Added error handling to connectWalletConnect method in ConnectionController to set wcError, wcFetchingUri, and status flags when connection fails
  • Bumped package version from 1.8.17 to 1.8.18
  • Added changeset documenting the fix

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/controllers/src/controllers/ConnectionController.ts Added catch handler to set error state flags when WalletConnect connection fails
packages/appkit/exports/constants.ts Version bump to 1.8.18
.changeset/quiet-hands-raise.md Changeset documenting the bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +249 to +255
.catch(() => {
state.wcError = true
state.wcFetchingUri = false
state.status = 'disconnected'

return undefined
})
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test case that verifies the error handling behavior when connectWalletConnect fails. The test should check that wcError, wcFetchingUri, and status are set correctly when the promise rejects. This would ensure the bug fix is properly covered and prevent regressions. See existing test at line 293 of ConnectionController.test.ts for a similar pattern.

Copilot uses AI. Check for mistakes.
Comment on lines +249 to +255
.catch(() => {
state.wcError = true
state.wcFetchingUri = false
state.status = 'disconnected'

return undefined
})
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a logic error in the error handling flow. When the promise rejects and the catch handler sets status to 'disconnected' (line 252), the promise continues execution. After awaiting the promise (line 257), the code unconditionally sets status to 'connected' (line 260), which overwrites the 'disconnected' status from the error handler. This means that even when an error occurs, the status will end up as 'connected'. Consider returning early from the function after the await if an error occurred, or check if wcError is true before setting the status to 'connected'.

Copilot uses AI. Check for mistakes.
Comment on lines +250 to +252
state.wcError = true
state.wcFetchingUri = false
state.status = 'disconnected'
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling here is inconsistent with the existing setWcError method (line 456-460). The setWcError method also sets state.buffering to false when handling errors. For consistency, state.buffering should also be set to false here, or consider using ConnectionController.setWcError(true) to ensure all related state is properly reset.

Suggested change
state.wcError = true
state.wcFetchingUri = false
state.status = 'disconnected'
ConnectionController.setWcError(true)

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

📦 Bundle Size Check

All bundles are within size limits

📊 View detailed bundle sizes

> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit


> size-limit

@reown/appkit - Main Entry
Size limit:   80 kB
Size:         75.62 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 625 ms   on Snapdragon 410
Total time:   2.2 s
@reown/appkit/react
Size limit:   235 kB
Size:         233.83 kB with all dependencies, minified and gzipped
Loading time: 4.6 s     on slow 3G
Running time: 2.7 s     on Snapdragon 410
Total time:   7.2 s
@reown/appkit/vue
Size limit:   80 kB
Size:         75.62 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 1.1 s    on Snapdragon 410
Total time:   2.6 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         213.72 kB with all dependencies, minified and gzipped
Loading time: 4.2 s     on slow 3G
Running time: 1.1 s     on Snapdragon 410
Total time:   5.3 s
@reown/appkit-ui
Size limit:   500 kB
Size:         13.16 kB with all dependencies, minified and gzipped
Loading time: 258 ms   on slow 3G
Running time: 170 ms   on Snapdragon 410
Total time:   427 ms

@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.66% 39606 / 50348
🔵 Statements 78.66% 39606 / 50348
🔵 Functions 76.36% 4251 / 5567
🔵 Branches 86.7% 9634 / 11111
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/controllers/src/controllers/ConnectionController.ts 84.9% 88.18% 53.76% 84.9% 176, 236-240, 243-247, 295-299, 307-308, 315-334, 349, 353, 357, 361, 365, 369, 373, 377, 381, 385, 468, 472, 494-498, 513-515, 526-527, 562-563, 573-574, 576-577, 585-586, 588-589, 608-609
Generated in workflow #16912 for commit 9323651 by the Vitest Coverage Report Action

tomiir and others added 2 commits February 18, 2026 09:39
Refactors .catch() to try/catch so status correctly stays 'disconnected'
on error instead of being overwritten to 'connected'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tomiir
Copy link
Collaborator Author

tomiir commented Feb 18, 2026

Added tests and a small refactor for the error handling:

Refactor: Replaced .catch() with try/catch block. The .catch() approach had a subtle bug — since it returned undefined, the promise resolved successfully and execution continued to state.status = 'connected', overwriting the 'disconnected' set in the catch. With try/catch, the success path is naturally skipped on error.

Tests (3 new):

  • wcError and status = 'disconnected' when connection rejects in cached mode (Telegram)
  • wcError and status = 'disconnected' when connection rejects with cache: 'always'
  • Negative test: wcError stays false and status = 'connected' on success

Comment on lines 260 to 262
} else {
await ConnectionController._getClient()?.connectWalletConnect?.()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to also add a catch here as well?

…atch

Lifts try/catch to wrap both cached and non-cached branches so error
state (wcError, wcFetchingUri, status) is set consistently. Re-throws
so callers like w3m-connecting-wc-view can still handle errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

4 participants