diff --git a/src/helpers/connCheck.ts b/src/helpers/connCheck.ts index 3dd40695..fc65411f 100644 --- a/src/helpers/connCheck.ts +++ b/src/helpers/connCheck.ts @@ -4,19 +4,11 @@ import type { Ipv4ServerResponse, } from '@/helpers/connCheck.types'; -/* -By default, it will retry twice because after connecting/disconnecting to/from Mullvad server, the first request results in a NetworkError and the second is successful. +export const connCheckIpv4 = async (): Promise => { + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 6000); -It's a workaround for the following bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1706377 -Workaround can be removed when Mullvad Browser 14.0 is released (the bug is fixed!). -*/ -const MAX_RETRIES = 3; - -export const connCheckIpv4 = async (retries = MAX_RETRIES): Promise => { try { - const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), 6000); - const response = await fetch('https://ipv4.am.i.mullvad.net/json', { method: 'GET', headers: { @@ -38,12 +30,11 @@ export const connCheckIpv4 = async (retries = MAX_RETRIES): Promise }; // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (error) { - if (retries === 1) throw new Error('IPv4 connection check failed.'); - return connCheckIpv4(retries - 1); + throw new Error('IPv4 connection check failed.'); } }; -export const connCheckIpv6 = async (retries = MAX_RETRIES): Promise => { +export const connCheckIpv6 = async (): Promise => { try { const response = await fetch('https://ipv6.am.i.mullvad.net/json', { method: 'GET', @@ -57,7 +48,6 @@ export const connCheckIpv6 = async (retries = MAX_RETRIES): Promise