File tree Expand file tree Collapse file tree 1 file changed +26
-6
lines changed
packages/web-wallet/src/contexts Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -363,21 +363,41 @@ export const WalletProvider: React.FC<WalletProviderProps> = ({ children }) => {
363363
364364 // Check for existing connection on mount
365365 React . useEffect ( ( ) => {
366+ let timeoutId : NodeJS . Timeout ;
367+
366368 // Add a small delay to avoid race condition with React StrictMode double-mount
367369 const timer = setTimeout ( ( ) => {
368- checkExistingConnection ( ) . catch ( ( error ) => {
369- console . error ( 'Connection check failed:' , error ) ;
370- // Ensure we reset the checking state on error
370+ // Set a timeout to prevent infinite hanging
371+ timeoutId = setTimeout ( ( ) => {
372+ console . error ( 'Connection check timed out after 10 seconds' ) ;
371373 setState ( prev => ( {
372374 ...prev ,
373375 isCheckingConnection : false ,
374376 loadingStep : '' ,
375- error : 'Failed to check connection' ,
377+ error : null ,
376378 } ) ) ;
377- } ) ;
379+ } , 10000 ) ;
380+
381+ checkExistingConnection ( )
382+ . catch ( ( error ) => {
383+ console . error ( 'Connection check failed:' , error ) ;
384+ // Ensure we reset the checking state on error
385+ setState ( prev => ( {
386+ ...prev ,
387+ isCheckingConnection : false ,
388+ loadingStep : '' ,
389+ error : 'Failed to check connection' ,
390+ } ) ) ;
391+ } )
392+ . finally ( ( ) => {
393+ clearTimeout ( timeoutId ) ;
394+ } ) ;
378395 } , 100 ) ;
379396
380- return ( ) => clearTimeout ( timer ) ;
397+ return ( ) => {
398+ clearTimeout ( timer ) ;
399+ if ( timeoutId ) clearTimeout ( timeoutId ) ;
400+ } ;
381401 } , [ ] ) ;
382402
383403 // Sync MetaMask errors to wallet state
You can’t perform that action at this time.
0 commit comments