Feature Request: Add optional timeout parameter to switchChain #5050
Unanswered
Zelys-DFKH
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
switchChaincan hang indefinitely on mobile wallets over WalletConnect when:The promise never rejects, leaving users stuck with no error feedback.
In production, we work around this with
Promise.race()+ manual 30-second timeouts, but this forces every consumer to re-implement the same fragile workaround.Proposed Solution
Add an optional
timeoutparameter (milliseconds) toswitchChain. If the request doesn't resolve within that window, the promise rejects with a clearSwitchChainTimeoutError.Implementation Notes
Following
waitForTransactionReceiptprecedent:SwitchChainParameterssetTimeout()+Promise.race()for timeout implementationSwitchChainTimeoutErrorextendingBaseErrorUse Case
DeFi apps need reliable chain switching before transaction submission. A timeout parameter eliminates the need for workarounds and gives developers control over their UX when wallets become unresponsive.
Beta Was this translation helpful? Give feedback.
All reactions