1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-01 13:53:11 +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) => { return new Promise<T>((resolve, reject) => {
let count = 0; let count = 0;
promises.forEach(promise => { promises.forEach((promise) => {
Promise.resolve(promise) Promise.resolve(promise)
.then(resolve) .then(resolve)
.catch(() => { .catch(() => {
@@ -44,7 +44,7 @@ const ping =
logger('ping failed', url, status, statusText); logger('ping failed', url, status, statusText);
throw new Error('Ping failed'); throw new Error('Ping failed');
}) })
.catch(e => { .catch((e) => {
pingFinished = true; pingFinished = true;
logger('ping error', url, e); logger('ping error', url, e);
throw e; throw e;
@@ -60,15 +60,16 @@ const ping =
]); ]);
}; };
export const testUrls = async (urls?: string[]) => { export const testUrls = async (urls?: string[]) => {
if (!urls?.length) { if (!urls?.length) {
return null; return null;
} }
const ret = await promiseAny(urls.map(ping)); try {
if (ret) { const ret = await promiseAny(urls.map(ping));
return ret; if (ret) {
} return ret;
}
} catch {}
logger('all ping failed, use first url:', urls[0]); logger('all ping failed, use first url:', urls[0]);
return urls[0]; return urls[0];
}; };

View File

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