Skip to content

Commit

Permalink
Blacklist and retry only on axios error
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Feb 22, 2024
1 parent 500317d commit 74d7d11
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/atlas/src/providers/uploads/uploads.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,17 @@ export const useStartFileUpload = () => {
setAssetStatus({ lastStatus: 'error', progress: 0 })

const axiosError = e as AxiosError
const networkFailure =
axiosError.isAxiosError &&
(!axiosError.response?.status || (axiosError.response.status >= 400 && axiosError.response.status <= 500))
const networkFailure = axiosError.isAxiosError

UserEventsLogger.logDistributorError({ dataObjectId: asset.id, distributorId: uploadOperator.id }, e)
// only retry on Axios error, otherwise code is to blame
if (networkFailure) {
markStorageOperatorFailed(uploadOperator.id)
}
UserEventsLogger.logDistributorError({ dataObjectId: asset.id, distributorId: uploadOperator.id }, e)

const retry = opts?.retry ?? 0
if (retry < MAX_BUCKET_RETRY) {
return startFileUpload(file, asset, { ...opts, retry: retry + 1 })
markStorageOperatorFailed(uploadOperator.id)
const retry = opts?.retry ?? 0
if (retry < MAX_BUCKET_RETRY) {
return startFileUpload(file, asset, { ...opts, retry: retry + 1 })
}
}

SentryLogger.error('Failed to upload asset', 'uploadsHooks', e, {
Expand Down

0 comments on commit 74d7d11

Please sign in to comment.