Skip to content

Commit 4a1d4d5

Browse files
committed
bump version to 10.30.2 and improve error handling in enhancedFetch function
1 parent 02517a9 commit 4a1d4d5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.30.1",
3+
"version": "10.30.2",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ export const assertWeb = () => {
108108
export const enhancedFetch = async (
109109
url: string,
110110
params: Parameters<typeof fetch>[1],
111-
) => {
111+
isRetry = false,
112+
): Promise<Response> => {
112113
return fetch(url, params)
113114
.then(r => {
114115
if (r.ok) {
@@ -118,7 +119,10 @@ export const enhancedFetch = async (
118119
})
119120
.catch(e => {
120121
log('fetch error', url, e);
122+
if (isRetry) {
123+
throw e;
124+
}
121125
log('trying fallback to http');
122-
return fetch(url.replace('https', 'http'), params);
126+
return enhancedFetch(url.replace('https', 'http'), params, true);
123127
});
124128
};

0 commit comments

Comments
 (0)