1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 10:21:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2025-04-10 12:15:43 +08:00
parent 3fe3daf599
commit d1920cdb4f
2 changed files with 9 additions and 8 deletions

View File

@@ -4,7 +4,7 @@ export function promiseAny<T>(promises: Promise<T>[]) {
return new Promise<T>((resolve, reject) => {
let count = 0;
promises.forEach(promise => {
promises.forEach((promise) => {
Promise.resolve(promise)
.then(resolve)
.catch(() => {
@@ -44,7 +44,7 @@ const ping =
logger('ping failed', url, status, statusText);
throw new Error('Ping failed');
})
.catch(e => {
.catch((e) => {
pingFinished = true;
logger('ping error', url, e);
throw e;
@@ -60,15 +60,16 @@ const ping =
]);
};
export const testUrls = async (urls?: string[]) => {
if (!urls?.length) {
return null;
}
const ret = await promiseAny(urls.map(ping));
if (ret) {
return ret;
}
try {
const ret = await promiseAny(urls.map(ping));
if (ret) {
return ret;
}
} catch {}
logger('all ping failed, use first url:', urls[0]);
return urls[0];
};

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "8.5.3",
"version": "8.5.4",
"description": "react-native hot update",
"main": "lib/index.ts",
"scripts": {