Skip to content

Conversation

mmarfinetz
Copy link

Summary

Fixes #2382 - Prevents app crash when wallet is locked while Supply modal is open

Changes

  • ✅ Fixed UserAuthenticated component to handle disconnection gracefully
  • ✅ Added WalletGuard provider to monitor wallet disconnection events
  • ✅ Enhanced SupplyModal with connection state guards
  • ✅ Added TransactionErrorBoundary for additional safety
  • ✅ Integrated providers in _app.page.tsx with proper hierarchy

Problem

When users lock their wallet extension (MetaMask/Rabby/Ambire) while the Supply modal is open, the app crashes with:

Uncaught Error: Invariant failed: User data loaded but no user found

Solution

Implemented a two-part defensive strategy:

  1. Global Wallet Guard: Monitors disconnection and closes modals automatically
  2. Component-Level Guards: Graceful handling with "Connect Wallet" UI

Testing

  1. Connect wallet (MetaMask/Rabby/Ambire)
  2. Open Supply modal
  3. Lock wallet extension
  4. Before: App crashes with client exception
  5. After: Modal gracefully shows "Connect Wallet" prompt

Impact

  • Improves UX reliability
  • Prevents data loss during wallet disconnection events
  • Establishes pattern for other transaction modals

Screenshots

N/A - Fix is for preventing crashes, behavior change is the absence of errors

Checklist

  • Code follows project conventions
  • No breaking changes
  • Tested with MetaMask, Rabby wallets
  • Ready for review

Fixes aave#2382 - Implements comprehensive wallet disconnection handling

Changes:
- Fix UserAuthenticated component to handle disconnection gracefully
  - Remove invariant assertion that caused crashes
  - Show "Connect Wallet" UI when user becomes undefined

- Add WalletGuard provider for global disconnection monitoring
  - Monitors wallet connection state via wagmi
  - Automatically closes all modals on disconnection
  - Prevents stale transaction state

- Enhance SupplyModal with disconnection guards
  - Check wallet connection before rendering modal content
  - Show appropriate "Connect Wallet" message when disconnected

- Add TransactionErrorBoundary for additional safety
  - Catches errors in transaction modals
  - Provides recovery mechanism for wallet-related errors
  - Prevents crashes from propagating to app level

This fix ensures the app handles wallet disconnection events (MetaMask lock,
Rabby lock, Ambire lock, etc.) gracefully without crashing, improving overall
UX reliability and preventing data loss during wallet disconnection events.
Copy link

vercel bot commented Aug 8, 2025

@mmarfinetz is attempting to deploy a commit to the Avara Team on Vercel.

A member of the Team first needs to authorize it.

@mmarfinetz
Copy link
Author

mmarfinetz commented Aug 8, 2025

Hi @sendra @foodaka @sakulstra @bpierre @grothem!

This PR fixes the critical wallet lock crash issue #2382 that affects users when their wallet extension (MetaMask/Rabby/Ambire) locks while modals are open.

The fix implements:

  • Graceful disconnection handling in UserAuthenticated
  • WalletGuard provider for global monitoring
  • Error boundaries for additional safety

This prevents the app from crashing and improves UX reliability. Would appreciate a review when you have a chance. Happy to make any adjustments needed!

Copy link
Author

@mmarfinetz mmarfinetz left a comment

Choose a reason for hiding this comment

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

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.

UI crash: A client-side exception has occurred

1 participant