fix: add timeout
This commit is contained in:
parent
a66f354c3b
commit
42e2051290
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.2.1",
|
||||
"version": "10.2.2",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
|
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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user