fix: don't show 'connected to' on connection error#381
Conversation
…ilure When a wallet connection fails (e.g., invalid credentials), getInfo() throws an error that was previously swallowed. This caused the UI to incorrectly show 'Connected through [name]' even though the connection failed. The outer catch block already handles disconnection and error display properly. By re-throwing the getInfo() error, we ensure it reaches that handler and the UI correctly reflects the failed connection state. Fixes getAlby#174
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA change to error handling in the store's provider connection flow. When Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks! this works well. However for NWC, I think we should also try to get the info as part of the connection. I tried to connect to a deleted NWC URL and it still shows connected successfully. Example URL: |
|
@Pyiner are you able to continue working on this PR? |
Summary
Fixes #174 — When a wallet connection fails (e.g., invalid LNbits credentials), the UI incorrectly shows "Connected through [name]" and the Disconnect button.
Root Cause
In
store.ts, thegetInfo()call's error is silently swallowed (lines 86-90). For connectors like LNbits,getInfo()makes a real API call to/api/v1/walletwhich fails with bad credentials. Since the error is caught and ignored, execution continues toset({ connected: true }), causing the UI to display connection success.The
bc-balancecomponent correctly shows the warning icon (becausegetBalance()also fails), but the rest of the UI still shows "connected."Fix
Re-throw the
getInfo()error so it propagates to the outercatchblock (line 114), which already:connecting: falsedisconnect()to clear the connection stateThis is the minimal correct fix — the error handling path already exists and works correctly; the inner catch was just preventing errors from reaching it.
Testing
Summary by CodeRabbit