File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -97,15 +97,21 @@ private actor LiveSessionManager {
9797            eventEmitter. emit ( . tokenRefreshed,  session:  session) 
9898
9999            return  session
100-           }  catch  let  error  as RetryableError  { 
101-             logger? . debug ( " Refresh token failed with a retryable error:  \( error) " ) 
102-             throw  error
103100          }  catch  { 
104-             logger? . debug ( " Refresh token failed with a non-retryable error:  \( error) " ) 
105- 
106-             remove ( ) 
107- 
108-             throw  error
101+             logger? . debug ( " Refresh token failed with error:  \( error) " ) 
102+ 
103+             // DO NOT remove session in case it is an error that should be retried.
104+             // i.e. server instability, connection issues, ...
105+             //
106+             // Need to do this check here, because not all RetryableError's should be retried.
107+             // URLError conforms to RetryableError, but only a subset of URLError should be retried,
108+             // the same is true for AuthError.
109+             if  let  error =  error as?  any  RetryableError ,  error. shouldRetry { 
110+               throw  error
111+             }  else  { 
112+               remove ( ) 
113+               throw  error
114+             } 
109115          } 
110116        } 
111117
Original file line number Diff line number Diff line change 66//
77import  Foundation
88
9+ /// An error type that can be retried.
910package   protocol  RetryableError :  Error  { 
11+   /// Whether this error instance should be retried or not.
1012  var  shouldRetry :  Bool  {  get  } 
1113} 
1214
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments