Browse Source

fix: add retry mechanism on failure

pull/9873/head
Pranav C 6 days ago
parent
commit
cbf80b0d32
  1. 8
      packages/nc-gui/composables/useApi/interceptors.ts

8
packages/nc-gui/composables/useApi/interceptors.ts

@ -1,6 +1,8 @@
import type { Api } from 'nocodb-sdk'
const DbNotFoundMsg = 'Database config not found'
const TIMEOUT_RETRY_COUNT = 1
export function addAxiosInterceptors(api: Api<any>) {
const state = useGlobal()
const router = useRouter()
@ -61,6 +63,8 @@ export function addAxiosInterceptors(api: Api<any>) {
return Promise.reject(error)
}
let retry = 0
do {
try {
const token = await state.refreshToken({
axiosInstance,
@ -91,10 +95,12 @@ export function addAxiosInterceptors(api: Api<any>) {
redirectToSignin: !isSharedPage,
skipApiCall: true,
})
return Promise.reject(error)
}
return Promise.reject(error)
if (retry >= TIMEOUT_RETRY_COUNT) return Promise.reject(error)
}
} while (retry++ < TIMEOUT_RETRY_COUNT)
},
)

Loading…
Cancel
Save