Skip to content

Commit 237aa63

Browse files
committed
fix: handle promise rejection in ExternalFluxAppDetails and remove duplicate initTimer declaration
1 parent 26d7b84 commit 237aa63

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Pages/App/Details/ExternalFlux/ExternalFluxAppDetails.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ const ExternalFluxAppDetails = () => {
6969
setAppDetailsError(null)
7070
}
7171

72+
/**
73+
* Throws error in case request is aborted
74+
*/
7275
const handleFetchExternalFluxCDAppDetails = () =>
7376
// NOTE: returning a promise so that we can trigger the next timeout after this api call completes
74-
new Promise<void>((resolve) => {
77+
new Promise<void>((resolve, reject) => {
7578
setIsReloadResourceTreeInProgress(true)
7679

7780
abortPreviousRequests(
@@ -87,6 +90,8 @@ const ExternalFluxAppDetails = () => {
8790
} else {
8891
setAppDetailsError(error)
8992
}
93+
} else {
94+
reject(error)
9095
}
9196
})
9297
.finally(() => {
@@ -107,7 +112,11 @@ const ExternalFluxAppDetails = () => {
107112
}
108113

109114
const handleReloadResourceTree = async () => {
110-
await handleFetchExternalFluxCDAppDetails()
115+
try {
116+
await handleFetchExternalFluxCDAppDetails()
117+
} catch {
118+
// do nothing
119+
}
111120
}
112121

113122
useEffect(() => {

src/components/externalArgoApps/ExternalArgoAppDetail.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import { AppDetails, AppType } from '../v2/appDetails/appDetails.type'
3232
import IndexStore from '../v2/appDetails/index.store'
3333
import { ExternalArgoAppDetailType } from './externalArgoApp.type'
3434

35+
let initTimer = null
36+
3537
const ExternalArgoAppDetail = ({ appName, clusterId, isExternalApp, namespace }: ExternalArgoAppDetailType) => {
3638
const location = useLocation()
3739
const history = useHistory()
3840
const [isLoading, setIsLoading] = useState(true)
3941
const [isReloadResourceTreeInProgress, setIsReloadResourceTreeInProgress] = useState(false)
4042
const [errorResponseCode, setErrorResponseCode] = useState(undefined)
4143

42-
let initTimer = null
4344
let isAPICallInProgress = false
4445

4546
const abortControllerRef = useRef<AbortController>(new AbortController())

src/components/v2/appDetails/ea/EAAppDetail.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import { getExternalLinks } from '../../../externalLinks/ExternalLinks.service'
4040
import { ExternalLinkIdentifierType, ExternalLinksAndToolsType } from '../../../externalLinks/ExternalLinks.type'
4141
import { sortByUpdatedOn } from '../../../externalLinks/ExternalLinks.utils'
4242

43+
let initTimer = null
44+
4345
const ExternalAppDetail = ({ appId, appName, isExternalApp }) => {
4446
const location = useLocation()
4547
const history = useHistory()
@@ -53,7 +55,6 @@ const ExternalAppDetail = ({ appId, appName, isExternalApp }) => {
5355

5456
const abortControllerRef = useRef<AbortController>(new AbortController())
5557

56-
let initTimer = null
5758
let isAPICallInProgress = false
5859

5960
// component load

0 commit comments

Comments
 (0)