Skip to content

Commit 10cb072

Browse files
committed
improve errorUpdate message
1 parent a432e5f commit 10cb072

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

Example/testHotUpdate/bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"react-native-paper": "^5.13.1",
1313
"react-native-safe-area-context": "^5.2.0",
1414
"react-native-svg": "^15.11.1",
15-
"react-native-update": "^10.25.0",
15+
"react-native-update": "^10.25.2",
1616
"react-native-vector-icons": "^10.2.0",
1717
},
1818
"devDependencies": {
@@ -1434,7 +1434,7 @@
14341434

14351435
"react-native-svg": ["react-native-svg@15.11.1", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-Qmwx/yJKt+AHUr4zjxx/Q69qwKtRfr1+uIfFMQoq3WFRhqU76aL9db1DyvPiY632DAsVGba1pHf92OZPkpjrdQ=="],
14361436

1437-
"react-native-update": ["react-native-update@10.25.0", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-4EYcYZFMhd/VMk9EwND4N2NOBZJYTksvbLdGTgqwYA1NT4IUmBgTFGeeng8GzazOqh4yP0tlW98zpW+67DEZsg=="],
1437+
"react-native-update": ["react-native-update@10.25.2", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-HI44TvCdkwXDbIzMKIcz4BK1my+dQYZz3GbiJJiv5/9Sqfl/uiLSr/Z9xUjX4O7G28N206KItORj7YK6yt/66w=="],
14381438

14391439
"react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="],
14401440

Example/testHotUpdate/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"react-native-paper": "^5.13.1",
2424
"react-native-safe-area-context": "^5.2.0",
2525
"react-native-svg": "^15.11.1",
26-
"react-native-update": "^10.25.0",
26+
"react-native-update": "^10.25.2",
2727
"react-native-vector-icons": "^10.2.0"
2828
},
2929
"devDependencies": {

android/src/main/java/cn/reactnative/modules/update/DownloadTask.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
4949

5050
private void removeDirectory(File file) throws IOException {
5151
if (UpdateContext.DEBUG) {
52-
Log.d("RNUpdate", "Removing " + file);
52+
Log.d("react-native-update", "Removing " + file);
5353
}
5454
if (file.isDirectory()) {
5555
File[] files = file.listFiles();
@@ -88,7 +88,7 @@ private void downloadFile(DownloadTaskParams param) throws IOException {
8888
BufferedSink sink = Okio.buffer(Okio.sink(writePath));
8989

9090
if (UpdateContext.DEBUG) {
91-
Log.d("RNUpdate", "Downloading " + url);
91+
Log.d("react-native-update", "Downloading " + url);
9292
}
9393

9494
long bytesRead = 0;
@@ -98,7 +98,7 @@ private void downloadFile(DownloadTaskParams param) throws IOException {
9898
received += bytesRead;
9999
sink.emit();
100100
if (UpdateContext.DEBUG) {
101-
Log.d("RNUpdate", "Progress " + received + "/" + contentLength);
101+
Log.d("react-native-update", "Progress " + received + "/" + contentLength);
102102
}
103103

104104
int percentage = (int)(received * 100.0 / contentLength + 0.5);
@@ -115,7 +115,7 @@ private void downloadFile(DownloadTaskParams param) throws IOException {
115115
sink.close();
116116

117117
if (UpdateContext.DEBUG) {
118-
Log.d("RNUpdate", "Download finished");
118+
Log.d("react-native-update", "Download finished");
119119
}
120120
}
121121

@@ -244,7 +244,7 @@ private void doFullPatch(DownloadTaskParams param) throws IOException {
244244

245245

246246
if (UpdateContext.DEBUG) {
247-
Log.d("RNUpdate", "Unzip finished");
247+
Log.d("react-native-update", "Unzip finished");
248248
}
249249
}
250250

@@ -260,7 +260,7 @@ private void copyFromResource(HashMap<String, ArrayList<File> > resToCopy) throw
260260
File lastTarget = null;
261261
for (File target: targets) {
262262
if (UpdateContext.DEBUG) {
263-
Log.d("RNUpdate", "Copying from resource " + fn + " to " + target);
263+
Log.d("react-native-update", "Copying from resource " + fn + " to " + target);
264264
}
265265
if (lastTarget != null) {
266266
copyFile(lastTarget, target);
@@ -352,7 +352,7 @@ private void doPatchFromApk(DownloadTaskParams param) throws IOException, JSONEx
352352
copyFromResource(copyList);
353353

354354
if (UpdateContext.DEBUG) {
355-
Log.d("RNUpdate", "Unzip finished");
355+
Log.d("react-native-update", "Unzip finished");
356356
}
357357

358358
}
@@ -418,12 +418,12 @@ private void doPatchFromPpk(DownloadTaskParams param) throws IOException, JSONEx
418418
throw new Error("bundle patch not found");
419419
}
420420
if (UpdateContext.DEBUG) {
421-
Log.d("RNUpdate", "Unzip finished");
421+
Log.d("react-native-update", "Unzip finished");
422422
}
423423
}
424424
private void doCleanUp(DownloadTaskParams param) throws IOException {
425425
if (UpdateContext.DEBUG) {
426-
Log.d("RNUpdate", "Start cleaning up");
426+
Log.d("react-native-update", "Start cleaning up");
427427
}
428428
File root = param.unzipDirectory;
429429
for (File sub : root.listFiles()) {
@@ -499,7 +499,7 @@ protected Void doInBackground(DownloadTaskParams... params) {
499499
default:
500500
break;
501501
}
502-
Log.e("pushy", "download task failed", e);
502+
Log.e("react-native-update", "download task failed", e);
503503

504504
if (params[0].listener != null) {
505505
params[0].listener.onDownloadFailed(e);

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.25.2",
3+
"version": "10.25.3",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/client.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export class Pushy {
361361
let succeeded = '';
362362
this.report({ type: 'downloading' });
363363
let lastError: any;
364+
let errorMessages: string[] = [];
364365
const diffUrl = await testUrls(joinUrls(paths, diff));
365366
if (diffUrl) {
366367
log('downloading diff');
@@ -372,11 +373,13 @@ export class Pushy {
372373
});
373374
succeeded = 'diff';
374375
} catch (e: any) {
375-
lastError = e;
376+
const errorMessage = `diff error: ${e.message}`;
377+
errorMessages.push(errorMessage);
378+
lastError = new Error(errorMessage);
376379
if (__DEV__) {
377380
succeeded = 'diff';
378381
} else {
379-
log(`diff error: ${e.message}, try pdiff`);
382+
log(errorMessage);
380383
}
381384
}
382385
}
@@ -390,11 +393,13 @@ export class Pushy {
390393
});
391394
succeeded = 'pdiff';
392395
} catch (e: any) {
393-
lastError = e;
396+
const errorMessage = `pdiff error: ${e.message}`;
397+
errorMessages.push(errorMessage);
398+
lastError = new Error(errorMessage);
394399
if (__DEV__) {
395400
succeeded = 'pdiff';
396401
} else {
397-
log(`pdiff error: ${e.message}, try full patch`);
402+
log(errorMessage);
398403
}
399404
}
400405
}
@@ -408,11 +413,13 @@ export class Pushy {
408413
});
409414
succeeded = 'full';
410415
} catch (e: any) {
411-
lastError = e;
416+
const errorMessage = `full patch error: ${e.message}`;
417+
errorMessages.push(errorMessage);
418+
lastError = new Error(errorMessage);
412419
if (__DEV__) {
413420
succeeded = 'full';
414421
} else {
415-
log(`full patch error: ${e.message}`);
422+
log(errorMessage);
416423
}
417424
}
418425
}
@@ -427,6 +434,7 @@ export class Pushy {
427434
this.report({
428435
type: 'errorUpdate',
429436
data: { newVersion: hash },
437+
message: errorMessages.join(';'),
430438
});
431439
if (lastError) {
432440
throw lastError;

0 commit comments

Comments
 (0)