Skip to content

Commit

Permalink
fix: add timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Mar 4, 2024
1 parent a66f354 commit 42e2051
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
11 changes: 7 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 42e2051

Please sign in to comment.