Skip to content

Commit 5785688

Browse files
committed
fix: abortController in external app
1 parent c1a40a3 commit 5785688

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/components/external-apps/ExternalAppService.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,15 @@ export const getAppDetail = async (
149149
return get(url, { abortControllerRef })
150150
}
151151

152-
export const getArgoAppDetail = (appName: string, clusterId: string, namespace: string) => {
153-
return get(`${Routes.ARGO_APPLICATION}?name=${appName}&clusterId=${clusterId}&namespace=${namespace}`)
154-
}
152+
export const getArgoAppDetail = async (
153+
appName: string,
154+
clusterId: string,
155+
namespace: string,
156+
abortControllerRef?: APIOptions['abortControllerRef'],
157+
) =>
158+
get(`${Routes.ARGO_APPLICATION}?name=${appName}&clusterId=${clusterId}&namespace=${namespace}`, {
159+
abortControllerRef,
160+
})
155161

156162
export const deleteApplicationRelease = (appId: string): Promise<UninstallReleaseResponse> => {
157163
const url = `${Routes.HELM_RELEASE_APP_DELETE_API}?appId=${appId}`

src/components/externalArgoApps/ExternalArgoAppDetail.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useState, useEffect } from 'react'
17+
import { useState, useEffect, useRef } from 'react'
1818
import { useLocation, useHistory } from 'react-router-dom'
1919
import {
2020
showError,
2121
Progressing,
2222
ErrorScreenManager,
2323
ServerErrors,
2424
DeploymentAppTypes,
25+
getIsRequestAborted,
2526
} from '@devtron-labs/devtron-fe-common-lib'
2627
import { getArgoAppDetail } from '../external-apps/ExternalAppService'
2728
import { checkIfToRefetchData, deleteRefetchDataFromUrl } from '../util/URLUtil'
@@ -40,10 +41,14 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
4041
let initTimer = null
4142
let isAPICallInProgress = false
4243

44+
const abortControllerRef = useRef<AbortController>(new AbortController())
45+
4346
// component load
4447
useEffect(() => {
4548
_init()
4649
return (): void => {
50+
abortControllerRef.current.abort()
51+
4752
if (initTimer) {
4853
clearTimeout(initTimer)
4954
}
@@ -72,7 +77,7 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
7277
const _getAndSetAppDetail = async () => {
7378
isAPICallInProgress = true
7479
setIsReloadResourceTreeInProgress(true)
75-
getArgoAppDetail(appName, clusterId, namespace)
80+
getArgoAppDetail(appName, clusterId, namespace, abortControllerRef)
7681
.then((appDetailResponse) => {
7782
const genericAppDetail: AppDetails = {
7883
...appDetailResponse.result,
@@ -82,8 +87,10 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
8287
setErrorResponseCode(undefined)
8388
})
8489
.catch((errors: ServerErrors) => {
85-
showError(errors)
86-
setErrorResponseCode(errors.code)
90+
if (!getIsRequestAborted(errors)) {
91+
showError(errors)
92+
setErrorResponseCode(errors.code)
93+
}
8794
})
8895
.finally(() => {
8996
setIsLoading(false)

0 commit comments

Comments
 (0)