14
14
* limitations under the License.
15
15
*/
16
16
17
- import { useEffect , useState } from 'react'
17
+ import { useEffect , useRef , useState } from 'react'
18
18
import { useParams } from 'react-router-dom'
19
19
20
20
import {
21
21
AppType ,
22
22
DeploymentAppTypes ,
23
23
ERROR_STATUS_CODE ,
24
24
ErrorScreenManager ,
25
+ getIsRequestAborted ,
25
26
IndexStore ,
26
27
noop ,
27
28
ResponseType ,
@@ -46,6 +47,15 @@ const ExternalFluxAppDetails = () => {
46
47
const [ isReloadResourceTreeInProgress , setIsReloadResourceTreeInProgress ] = useState ( true )
47
48
const [ appDetailsError , setAppDetailsError ] = useState ( null )
48
49
50
+ const abortControllerRef = useRef < AbortController > ( new AbortController ( ) )
51
+
52
+ useEffect (
53
+ ( ) => ( ) => {
54
+ abortControllerRef . current . abort ( )
55
+ } ,
56
+ [ ] ,
57
+ )
58
+
49
59
const handleUpdateIndexStoreWithDetails = ( response : ResponseType < any > ) => {
50
60
const genericAppDetail : AppDetails = {
51
61
...response . result ,
@@ -63,13 +73,15 @@ const ExternalFluxAppDetails = () => {
63
73
new Promise < void > ( ( resolve ) => {
64
74
setIsReloadResourceTreeInProgress ( true )
65
75
66
- getExternalFluxCDAppDetails ( clusterId , namespace , appName , isKustomization )
76
+ getExternalFluxCDAppDetails ( clusterId , namespace , appName , isKustomization , abortControllerRef )
67
77
. then ( handleUpdateIndexStoreWithDetails )
68
78
. catch ( ( error ) => {
69
- if ( ! initialLoading ) {
70
- showError ( error )
71
- } else {
72
- setAppDetailsError ( error )
79
+ if ( ! getIsRequestAborted ( error ) ) {
80
+ if ( ! initialLoading ) {
81
+ showError ( error )
82
+ } else {
83
+ setAppDetailsError ( error )
84
+ }
73
85
}
74
86
} )
75
87
. finally ( ( ) => {
0 commit comments