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 { getArgoAppDetail } from '../external-apps/ExternalAppService'
27
28
import { checkIfToRefetchData , deleteRefetchDataFromUrl } from '../util/URLUtil'
@@ -40,10 +41,14 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
40
41
let initTimer = null
41
42
let isAPICallInProgress = false
42
43
44
+ const abortControllerRef = useRef < AbortController > ( new AbortController ( ) )
45
+
43
46
// component load
44
47
useEffect ( ( ) => {
45
48
_init ( )
46
49
return ( ) : void => {
50
+ abortControllerRef . current . abort ( )
51
+
47
52
if ( initTimer ) {
48
53
clearTimeout ( initTimer )
49
54
}
@@ -72,7 +77,7 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
72
77
const _getAndSetAppDetail = async ( ) => {
73
78
isAPICallInProgress = true
74
79
setIsReloadResourceTreeInProgress ( true )
75
- getArgoAppDetail ( appName , clusterId , namespace )
80
+ getArgoAppDetail ( appName , clusterId , namespace , abortControllerRef )
76
81
. then ( ( appDetailResponse ) => {
77
82
const genericAppDetail : AppDetails = {
78
83
...appDetailResponse . result ,
@@ -82,8 +87,10 @@ const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }:
82
87
setErrorResponseCode ( undefined )
83
88
} )
84
89
. catch ( ( errors : ServerErrors ) => {
85
- showError ( errors )
86
- setErrorResponseCode ( errors . code )
90
+ if ( ! getIsRequestAborted ( errors ) ) {
91
+ showError ( errors )
92
+ setErrorResponseCode ( errors . code )
93
+ }
87
94
} )
88
95
. finally ( ( ) => {
89
96
setIsLoading ( false )
0 commit comments