Skip to content

Commit e168663

Browse files
committed
fix: improve internet connectivity fetch with timeout handling and cleanup
1 parent 8482353 commit e168663

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/services/service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,15 @@ export const getTemplateOptions = (appId: number, envId: number): Promise<Respon
559559
get(getUrlWithSearchParams(Routes.DEPLOYMENT_OPTIONS, { appId, envId }))
560560

561561
export const getInternetConnectivity = (controller: AbortController): Promise<any> => {
562-
setTimeout(() => {
562+
const timeoutId = setTimeout(() => {
563563
controller.abort()
564564
}, 10000)
565565

566566
return fetch(`${window._env_?.CENTRAL_API_ENDPOINT ?? 'https://api.devtron.ai'}/${Routes.HEALTH}`, {
567567
signal: controller.signal,
568-
}).then((res) => res.json())
568+
})
569+
.then((res) => res.json())
570+
.finally(() => {
571+
clearTimeout(timeoutId)
572+
})
569573
}

0 commit comments

Comments
 (0)