@@ -91,10 +91,16 @@ export const loginWithPasswordlessCode = withRetries('loginPWL', async (email: s
9191 shouldThrow : ( e ) => {
9292 console . log ( `PWL login failed with status ${ e . statusCode } : ${ e . message } ` ) ;
9393
94- // Don't retry request errors (e.g. auth failure) - return them directly
95- if ( e ?. statusCode >= 400 && e ?. statusCode < 500 ) {
96- return new StatusError ( 401 , "Login failed" )
97- } else return undefined ;
94+ if ( e ?. statusCode === 403 ) {
95+ // Don't retry hard authentication failures - return them explicitly
96+ return new StatusError ( 403 , "Login failed" )
97+ } else if ( e ?. statusCode >= 400 && e ?. statusCode < 500 ) {
98+ // Don't retry other request errors
99+ return new StatusError ( 500 , "Error during login" )
100+ } else {
101+ // We do retry all kinds of connection or server errors (500+)
102+ return undefined ;
103+ }
98104 }
99105 }
100106) ;
@@ -108,10 +114,16 @@ export const refreshToken = withRetries('refreshToken', async (refreshToken: str
108114 shouldThrow : ( e ) => {
109115 console . log ( `Refresh token failed with status ${ e . statusCode } : ${ e . message } ` ) ;
110116
111- // Don't retry request errors (e.g. auth failure) - return them directly
112- if ( e ?. statusCode >= 400 && e ?. statusCode < 500 ) {
113- return new StatusError ( 401 , "Token refresh failed" )
114- } else return undefined ;
117+ if ( e ?. statusCode === 403 ) {
118+ // Don't retry hard authentication failures - return them explicitly
119+ return new StatusError ( 403 , "Token refresh failed" )
120+ } else if ( e ?. statusCode >= 400 && e ?. statusCode < 500 ) {
121+ // Don't retry other request errors
122+ return new StatusError ( 500 , "Error during token refresh" )
123+ } else {
124+ // We do retry all kinds of connection or server errors (500+)
125+ return undefined ;
126+ }
115127 }
116128 }
117129)
0 commit comments