|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -import React, { useState, useEffect } from 'react' |
| 17 | +import { useState, useEffect, useRef } from 'react' |
18 | 18 | import { useLocation, useHistory } from 'react-router-dom'
|
19 | 19 | import {
|
20 | 20 | showError,
|
21 | 21 | Progressing,
|
22 | 22 | ErrorScreenManager,
|
23 | 23 | ServerErrors,
|
24 | 24 | DeploymentAppTypes,
|
| 25 | + getIsRequestAborted, |
25 | 26 | } from '@devtron-labs/devtron-fe-common-lib'
|
26 | 27 | import moment from 'moment'
|
27 | 28 | import { sortOptionsByValue } from '../../../common'
|
@@ -49,13 +50,17 @@ const ExternalAppDetail = ({ appId, appName, isExternalApp }) => {
|
49 | 50 | })
|
50 | 51 | const [isReloadResourceTreeInProgress, setIsReloadResourceTreeInProgress] = useState(false)
|
51 | 52 |
|
| 53 | + const abortControllerRef = useRef<AbortController>(new AbortController()) |
| 54 | + |
52 | 55 | let initTimer = null
|
53 | 56 | let isAPICallInProgress = false
|
54 | 57 |
|
55 | 58 | // component load
|
56 | 59 | useEffect(() => {
|
57 | 60 | _init()
|
58 | 61 | return (): void => {
|
| 62 | + abortControllerRef.current.abort() |
| 63 | + |
59 | 64 | if (initTimer) {
|
60 | 65 | clearTimeout(initTimer)
|
61 | 66 | }
|
@@ -120,7 +125,7 @@ const ExternalAppDetail = ({ appId, appName, isExternalApp }) => {
|
120 | 125 | const _getAndSetAppDetail = () => {
|
121 | 126 | isAPICallInProgress = true
|
122 | 127 | setIsReloadResourceTreeInProgress(true)
|
123 |
| - getAppDetail(appId) |
| 128 | + getAppDetail(appId, abortControllerRef) |
124 | 129 | .then((appDetailResponse: HelmAppDetailResponse) => {
|
125 | 130 | IndexStore.publishAppDetails(
|
126 | 131 | _convertToGenericAppDetailModel(appDetailResponse.result),
|
@@ -159,8 +164,11 @@ const ExternalAppDetail = ({ appId, appName, isExternalApp }) => {
|
159 | 164 | setErrorResponseCode(undefined)
|
160 | 165 | })
|
161 | 166 | .catch((errors: ServerErrors) => {
|
162 |
| - showError(errors) |
163 |
| - setErrorResponseCode(errors.code) |
| 167 | + if (!getIsRequestAborted(errors)) { |
| 168 | + showError(errors) |
| 169 | + setErrorResponseCode(errors.code) |
| 170 | + } |
| 171 | + |
164 | 172 | setIsLoading(false)
|
165 | 173 | isAPICallInProgress = false
|
166 | 174 | })
|
|
0 commit comments