mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-18 21:00:38 +08:00
fix: add timeout
This commit is contained in:
11
src/utils.ts
11
src/utils.ts
@@ -9,10 +9,13 @@ export function assertRelease() {
|
||||
}
|
||||
|
||||
const ping = async (url: string) =>
|
||||
fetch(url, {
|
||||
method: 'HEAD',
|
||||
redirect: 'follow',
|
||||
}).then(({ status }) => status === 200);
|
||||
Promise.race([
|
||||
fetch(url, {
|
||||
method: 'HEAD',
|
||||
redirect: 'follow',
|
||||
}).then(({ status }) => status === 200),
|
||||
new Promise<false>((r) => setTimeout(() => r(false), 2000)),
|
||||
]);
|
||||
|
||||
const canUseGoogle = ping('https://www.google.com');
|
||||
|
||||
|
Reference in New Issue
Block a user