1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

fix: add timeout

This commit is contained in:
sunnylqm 2024-03-04 12:30:00 +08:00
parent a66f354c3b
commit 42e2051290
No known key found for this signature in database
2 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.2.1", "version": "10.2.2",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index.ts", "main": "src/index.ts",
"scripts": { "scripts": {

View File

@ -9,10 +9,13 @@ export function assertRelease() {
} }
const ping = async (url: string) => const ping = async (url: string) =>
fetch(url, { Promise.race([
method: 'HEAD', fetch(url, {
redirect: 'follow', method: 'HEAD',
}).then(({ status }) => status === 200); redirect: 'follow',
}).then(({ status }) => status === 200),
new Promise<false>((r) => setTimeout(() => r(false), 2000)),
]);
const canUseGoogle = ping('https://www.google.com'); const canUseGoogle = ping('https://www.google.com');