From 4a1d4d5a501b8f52f6b7b37d54e23ec524250e7d Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Sat, 30 Aug 2025 11:53:52 +0800 Subject: [PATCH] bump version to 10.30.2 and improve error handling in enhancedFetch function --- package.json | 2 +- src/utils.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c1feb19..fa13a03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "10.30.1", + "version": "10.30.2", "description": "react-native hot update", "main": "src/index", "scripts": { diff --git a/src/utils.ts b/src/utils.ts index 1b090e8..0e3546c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -108,7 +108,8 @@ export const assertWeb = () => { export const enhancedFetch = async ( url: string, params: Parameters[1], -) => { + isRetry = false, +): Promise => { return fetch(url, params) .then(r => { if (r.ok) { @@ -118,7 +119,10 @@ export const enhancedFetch = async ( }) .catch(e => { log('fetch error', url, e); + if (isRetry) { + throw e; + } log('trying fallback to http'); - return fetch(url.replace('https', 'http'), params); + return enhancedFetch(url.replace('https', 'http'), params, true); }); };