Skip to content

Fix wallet connect button hanging on rejected connection - #263

Merged
arisu6804 merged 2 commits into
RemitFlow:mainfrom
Unclebaffa:wallet-connect-button-hangs
Jul 22, 2026
Merged

Fix wallet connect button hanging on rejected connection#263
arisu6804 merged 2 commits into
RemitFlow:mainfrom
Unclebaffa:wallet-connect-button-hangs

Conversation

@Unclebaffa

Copy link
Copy Markdown
Contributor

Summary

I've successfully fixed the wallet connect button hanging issue on rejected connections. Here's what was done:

Changes Made

1. Error State Management (AppContext.jsx)

  • Added connectionError state to track connection failures
  • Implemented proper try-catch-finally error handling in the connect() function
  • Added 30-second timeout protection using Promise.race() to prevent indefinite hanging
  • Errors are automatically cleared on disconnect or retry attempts

2. User Feedback (WalletButton.jsx)

  • Added error alert display using the existing Alert component
  • Wrapped connect call in handleConnect to properly catch errors
  • Error messages appear below the button when connection fails
  • Button re-enables immediately after errors

3. Realistic Testing (wallet.js)

  • Updated mock wallet service to simulate connection rejections (10% chance)
  • Properly handles promise rejection instead of always resolving
  • Prepares codebase for real wallet provider integration

4. Hook Interface (useWallet.js)

  • Added connectionError to the hook's return values
  • Updated documentation to reflect the new error state

Test Coverage Added

3 new/updated test files with comprehensive coverage:

  • test/services/wallet.test.js - Enhanced with rejection scenarios and storage tests
  • test/unit/AppContext.wallet.test.jsx - New file testing error handling, timeout, and state management
  • test/components/WalletButton.test.jsx - New file testing UI error feedback and user flows

Documentation Updated

  • README.md - Added wallet error handling features and test documentation
  • WALLET_FIX_SUMMARY.md - Detailed summary document of all changes

Acceptance Criteria

Implemented the change - Button no longer hangs on rejected connections
Added automated tests - Comprehensive test coverage for all scenarios
Updated documentation - README and summary documentation complete

All Changes Committed

Commit: d5673a3 - "Fix wallet connect button hanging on rejected connection"
8 files changed, 524 insertions(+), 11 deletions(-)

The wallet connect button now provides proper user feedback, handles timeouts, and gracefully recovers from connection failures.

Closes #2

- Add error state management in AppContext for connection failures
- Implement 30-second timeout to prevent indefinite hanging
- Add proper error handling with try-catch in connect function
- Display error alerts in WalletButton when connection fails
- Clear errors on disconnect and retry attempts
- Update wallet service to simulate connection rejections (10% chance)
- Add comprehensive test coverage:
  - Wallet service tests for rejection scenarios
  - AppContext tests for error handling and timeout
  - WalletButton tests for UI error feedback
- Update README with enhanced wallet features documentation
@arisu6804

Copy link
Copy Markdown
Contributor

Really tidy PR — appreciate the detail. ✅

@Unclebaffa

Copy link
Copy Markdown
Contributor Author

Really tidy PR — appreciate the detail. ✅

Conflict resolved and this branch is ready for merge

@arisu6804

Copy link
Copy Markdown
Contributor

Great work, merged. 🎉

@arisu6804
arisu6804 merged commit acd9e7c into RemitFlow:main Jul 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wallet connect button hangs on a rejected connection

2 participants