Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main - check API errors when updating tasks and ask to retry... #693

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion packages/corejs/src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,27 @@ const RETRY_CONFIG = {
retries: MAX_RETRY_ATTEMPTS,
retryDelay: (retryCount: number) => axiosRetry.exponentialDelay(retryCount),
// shouldResetTimeout: true,
retryCondition: (error: AxiosError) => axiosRetry.isNetworkOrIdempotentRequestError(error) || error?.response?.status === 500,
retryCondition: (error: AxiosError) => {
// Check if the error response is in a range of server error status codes (5xx)
const hasServerError = error.response && error.response.status >= 500 && error.response.status <= 599;

// Check if the error is a CORS error
const isCorsError = /cors/i.test(error.message);

// Check if the error is a network or idempotent request error
const isNetworkError = axiosRetry.isNetworkOrIdempotentRequestError(error);

// Add a custom check for specific error messages
const isCustomNetworkError = error.message && error.message === 'Network Error';

// Check for other common conditions that you might want to retry
const shouldRetry = hasServerError
|| isCorsError
|| isNetworkError
|| isCustomNetworkError;

return shouldRetry;
},
};

/**
Expand Down
Loading