Skip to content

Commit

Permalink
fix: update internetReachability fetch abort (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
gizomo committed Dec 12, 2023
1 parent edd46de commit d44d5a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/internal/internetReachability.ts
Expand Up @@ -89,8 +89,8 @@ export default class InternetReachability {
// Create promise that makes it possible to cancel a pending request through a reject
// eslint-disable-next-line @typescript-eslint/no-empty-function
let cancel: () => void = (): void => {};
const cancelPromise = new Promise<Response>((): void => {
cancel = (): void => controller.abort('canceled');
const cancelPromise = new Promise<Response>((_, reject): void => {
cancel = (): void => reject('canceled');
});

const promise = Promise.race([
Expand All @@ -117,7 +117,9 @@ export default class InternetReachability {
)
.catch(
(error: Error | 'timedout' | 'canceled'): void => {
if (error !== 'canceled') {
if ('canceled' === error) {
controller.abort();
} else {
this._setIsInternetReachable(false);
this._currentTimeoutHandle = setTimeout(
this._checkInternetReachability,
Expand Down

0 comments on commit d44d5a8

Please sign in to comment.