Skip to content

Commit 23b88f5

Browse files
committed
fix: add abortController for scale workloads
1 parent f9747c1 commit 23b88f5

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/components/v2/appDetails/appDetails.api.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ export const getInstalledChartNotesDetail = (_appId: number, _envId: number) =>
4646
return get(`${Routes.APP_STORE_INSTALLED_APP}/notes?installed-app-id=${_appId}&env-id=${_envId}`)
4747
}
4848

49-
export const getInstalledChartDetailWithResourceTree = (_appId: number, _envId: number) => {
50-
return get(`${Routes.APP_STORE_INSTALLED_APP}/resource/hibernate?installed-app-id=${_appId}&env-id=${_envId}`)
51-
}
49+
export const getInstalledChartDetailWithResourceTree = (
50+
_appId: number,
51+
_envId: number,
52+
abortControllerRef?: APIOptions['abortControllerRef'],
53+
) =>
54+
get(`${Routes.APP_STORE_INSTALLED_APP}/resource/hibernate?installed-app-id=${_appId}&env-id=${_envId}`, {
55+
abortControllerRef,
56+
})
5257

5358
export const getInstalledAppDetail = (_appId: number, _envId: number) => {
5459
return get(`app/detail?app-id=${_appId}&env-id=${_envId}`)

src/components/v2/appDetails/sourceInfo/scaleWorkloads/ScaleWorkloadsModal.component.tsx

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

17-
import { useEffect, useState } from 'react'
17+
import { useEffect, useRef, useState } from 'react'
1818
import {
1919
showError,
2020
Progressing,
@@ -23,6 +23,7 @@ import {
2323
Checkbox,
2424
DeploymentAppTypes,
2525
TabGroup,
26+
getIsRequestAborted,
2627
} from '@devtron-labs/devtron-fe-common-lib'
2728
import { ReactComponent as Info } from '../../../../../assets/icons/ic-info-filled.svg'
2829
import { ReactComponent as Close } from '../../../../../assets/icons/ic-close.svg'
@@ -66,8 +67,14 @@ export default function ScaleWorkloadsModal({ appId, onClose, history }: ScaleWo
6667
const isHelmApp =
6768
appDetails.appType === AppType.DEVTRON_HELM_CHART || appDetails.appType === AppType.EXTERNAL_HELM_CHART
6869

70+
const abortControllerRef = useRef<AbortController>(new AbortController())
71+
6972
useEffect(() => {
7073
_getAndSetAppDetail()
74+
75+
return () => {
76+
abortControllerRef.current.abort()
77+
}
7178
}, [])
7279

7380
useEffect(() => {
@@ -122,11 +129,14 @@ export default function ScaleWorkloadsModal({ appId, onClose, history }: ScaleWo
122129
const response = await getInstalledChartDetailWithResourceTree(
123130
+appDetails.installedAppId,
124131
+appDetails.environmentId,
132+
abortControllerRef,
125133
)
126134
IndexStore.publishAppDetails(response.result, AppType.DEVTRON_HELM_CHART)
127135
}
128136
} catch (e) {
129-
showError(e)
137+
if (!getIsRequestAborted(e)) {
138+
showError(e)
139+
}
130140
} finally {
131141
setfetchingDetails(false)
132142
}

0 commit comments

Comments
 (0)