Skip to content

Commit d859b89

Browse files
committed
chore: getIsRequestAborted check added
1 parent 4d5eef2 commit d859b89

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/common/hooks/useOnline/useOnline.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ export const useOnline = ({ onOnline = noop }: { onOnline?: () => void }) => {
3838

3939
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
4040
} catch (error) {
41+
if (getIsRequestAborted(error)) return
42+
const fallbackController = new AbortController()
43+
abortControllerRef.current = fallbackController
4144
try {
42-
await getFallbackInternetConnectivity(abortControllerRef.current)
45+
await getFallbackInternetConnectivity(fallbackController)
4346
onConnectivitySuccess()
4447
} catch {
4548
setOnline(false)
4649
} finally {
47-
if (!getIsRequestAborted(error)) {
48-
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
49-
}
50+
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
5051
}
5152
}
5253
}

0 commit comments

Comments
 (0)