-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK] useAutoConnect to throw error #5742
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
setConnectionStatus("disconnected"); | ||
if (e instanceof Error) { | ||
console.warn("Error auto connecting wallet:", e.message); | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state update to setConnectionStatus
may be interrupted by the subsequent throw
. Consider either:
- Removing
throw e
to allow the state to update properly, or - Wrapping the state update in a
setTimeout
to ensure it completes before the error propagates
The choice depends on whether error propagation or state consistency is more important for this use case.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def don't want to throw here. autoconnecting can fail for legit reasons (auth token expired, extension locked, etc)
what would be acceptable is to let the user pass an onError callback or return the error like any other mutation/query hook
size-limit report 📦
|
setConnectionStatus("disconnected"); | ||
if (e instanceof Error) { | ||
console.warn("Error auto connecting wallet:", e.message); | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def don't want to throw here. autoconnecting can fail for legit reasons (auth token expired, extension locked, etc)
what would be acceptable is to let the user pass an onError callback or return the error like any other mutation/query hook
Problem solved
Short description of the bug fixed or feature added
PR-Codex overview
This PR focuses on improving error handling in the
useAutoConnect
hook by ensuring the connection status is set to "disconnected" when an error occurs during the wallet auto-connection process.Detailed summary
setConnectionStatus("disconnected");
inside thecatch
block to handle errors.setConnectionStatus("disconnected");
from the else block.