@onekeyfe/react-native-bundle-update 3.0.30 → 3.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/src/main/java/com/margelo/nitro/reactnativebundleupdate/ReactNativeBundleUpdate.kt
CHANGED
|
@@ -409,10 +409,12 @@ object BundleUpdateStoreAndroid {
|
|
|
409
409
|
/**
|
|
410
410
|
* Subtype of the most recent calculateSHA256 failure on this thread, or
|
|
411
411
|
* null if the last call succeeded. Surfaces the specific reason —
|
|
412
|
-
* FILE_NOT_FOUND /
|
|
413
|
-
* UNEXPECTED_<class> — so
|
|
414
|
-
*
|
|
415
|
-
* verifyPackage failures)
|
|
412
|
+
* FILE_NOT_FOUND / FILE_DISAPPEARED / FILE_TRUNCATED /
|
|
413
|
+
* PERMISSION_DENIED / OOM / IO_<class> / UNEXPECTED_<class> — so
|
|
414
|
+
* analytics can split the previously opaque "Failed to calculate
|
|
415
|
+
* SHA256" bucket (mixpanel: 91.3 percent of verifyPackage failures)
|
|
416
|
+
* into actionable categories. Keep this list in sync with the
|
|
417
|
+
* lastSHA256Failure.set(...) call sites in calculateSHA256 below.
|
|
416
418
|
*
|
|
417
419
|
* Note: 0-byte files are NOT treated as a failure. They hash to the
|
|
418
420
|
* well-known empty-content SHA-256 and the caller's expected/actual
|
|
@@ -1576,8 +1578,16 @@ class ReactNativeBundleUpdate : HybridReactNativeBundleUpdateSpec() {
|
|
|
1576
1578
|
// matches the verbatim guarantees documented on
|
|
1577
1579
|
// sanitizeErrorMessageForEvent.
|
|
1578
1580
|
OneKeyLog.error("BundleUpdate", "downloadBundle: failed: ${e.javaClass.simpleName}: ${e.message}")
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
+
val sanitized = sanitizeErrorMessageForEvent(e)
|
|
1582
|
+
sendEvent("update/error", message = sanitized)
|
|
1583
|
+
// Rethrow with the same sanitized message so the Promise
|
|
1584
|
+
// rejection surfacing to JS carries no /data/user/<u>/<pkg>/
|
|
1585
|
+
// paths. Without this rewrap, FileNotFoundException etc.
|
|
1586
|
+
// would re-leak via Promise.reject's message channel even
|
|
1587
|
+
// though the event payload was already sanitized. Keep
|
|
1588
|
+
// the original exception as `cause` so OneKeyLog (and any
|
|
1589
|
+
// native crash reporter) still sees the full chain.
|
|
1590
|
+
throw Exception(sanitized, e)
|
|
1581
1591
|
} finally {
|
|
1582
1592
|
isDownloading.set(false)
|
|
1583
1593
|
}
|
|
@@ -1283,9 +1283,14 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
|
|
|
1283
1283
|
private func snapshotResumeDataForBackgrounding() {
|
|
1284
1284
|
guard let session = self.urlSession else { return }
|
|
1285
1285
|
// Read both isDownloading AND activeDownloadFilePath inside the
|
|
1286
|
-
// same stateQueue.sync block
|
|
1287
|
-
//
|
|
1288
|
-
//
|
|
1286
|
+
// same stateQueue.sync block. A concurrent downloadBundle entry
|
|
1287
|
+
// flips isDownloading=true at the start of the Promise body but
|
|
1288
|
+
// only writes activeDownloadFilePath later (after the early
|
|
1289
|
+
// guards / version + URL validation). Without this paired read,
|
|
1290
|
+
// didEnterBackground could observe isDownloading=true while
|
|
1291
|
+
// activeDownloadFilePath is still nil from a previous run, or —
|
|
1292
|
+
// on the unwind via defer — see isDownloading=false alongside a
|
|
1293
|
+
// not-yet-cleared path.
|
|
1289
1294
|
let snapshot: (Bool, String?) = self.stateQueue.sync {
|
|
1290
1295
|
(self.isDownloading, self.activeDownloadFilePath)
|
|
1291
1296
|
}
|
|
@@ -1542,7 +1547,19 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
|
|
|
1542
1547
|
let nsError = error as NSError
|
|
1543
1548
|
OneKeyLog.error("BundleUpdate", "downloadBundle: download failed: \(nsError.domain) \(nsError.code) \(nsError.localizedDescription)")
|
|
1544
1549
|
self.sendEvent(type: "update/error", message: "\(nsError.domain) \(nsError.code)")
|
|
1545
|
-
|
|
1550
|
+
// Rethrow a sanitized NSError. The original `error` is a
|
|
1551
|
+
// URLSession/system error whose `localizedDescription` may
|
|
1552
|
+
// include the temp file path (e.g. NSURLErrorFailingURLString
|
|
1553
|
+
// userInfo, or the ~/Library/.../CFNetworkDownload_*.tmp
|
|
1554
|
+
// path on cancel-with-resume) — Promise rejections surface
|
|
1555
|
+
// that string to JS, which would re-leak the paths the
|
|
1556
|
+
// event-payload sanitization just stripped. Keep the full
|
|
1557
|
+
// detail in OneKeyLog (above) and emit only `domain code`.
|
|
1558
|
+
throw NSError(
|
|
1559
|
+
domain: nsError.domain,
|
|
1560
|
+
code: nsError.code,
|
|
1561
|
+
userInfo: [NSLocalizedDescriptionKey: "Download failed: \(nsError.domain) \(nsError.code)"]
|
|
1562
|
+
)
|
|
1546
1563
|
|
|
1547
1564
|
case .success(let (tempURL, response)):
|
|
1548
1565
|
// Successful completion ⇒ no longer need the resume blob.
|