AAE-30358 Update Retry connection logic to allow retry when the graphql return unauthorized error

This commit is contained in:
alep85 2025-04-14 14:56:26 +02:00
parent 76999ee830
commit 10346dbf1f
No known key found for this signature in database
GPG Key ID: AB4BE8E091FD24C8

View File

@ -141,9 +141,25 @@ export class WebSocketService {
max: Number.POSITIVE_INFINITY, max: Number.POSITIVE_INFINITY,
jitter: true jitter: true
}, },
attempts: { attempts: (count: number, _operation: Operation, error: any) => {
max: 5, if (!error) {
retryIf: (error) => !!error return false;
}
const isUnauthorizedError =
(Array.isArray(error) &&
error.some(
(err: any) =>
err?.extensions?.code === 'UNAUTHORIZED' ||
err?.message?.includes('4401') ||
err?.message?.toLowerCase().includes('unauthorized')
)) ||
(typeof error === 'string' && (error.includes('4401') || error.toLowerCase().includes('unauthorized'))) ||
(error?.message && (error.message.includes('4401') || error.message.toLowerCase().includes('unauthorized')));
const shouldRetry = isUnauthorizedError ? this.authService.isLoggedIn() : count < 5;
return shouldRetry;
} }
}); });