@onekeyfe/react-native-bundle-update 3.0.31 → 3.0.32

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.
@@ -1489,7 +1489,14 @@ class ReactNativeBundleUpdate : HybridReactNativeBundleUpdateSpec() {
1489
1489
  partialBytes = 0L
1490
1490
  }
1491
1491
 
1492
- val body = response.body ?: throw Exception("Empty response body")
1492
+ // Close the response before throwing on a null body — OkHttp
1493
+ // holds connection resources on the response wrapper itself,
1494
+ // and `throw` here exits the function before any byteStream()
1495
+ // consumption would close it for us.
1496
+ val body = response.body ?: run {
1497
+ response.close()
1498
+ throw Exception("Empty response body")
1499
+ }
1493
1500
  val contentLength = body.contentLength()
1494
1501
  // Total size of the whole resource (not the slice). On 206 prefer
1495
1502
  // Content-Range's "/total" tail; fall back to partial+contentLength.
@@ -315,11 +315,15 @@ public class BundleUpdateStore: NSObject {
315
315
 
316
316
  /// Subtype of the most recent calculateSHA256 failure on this thread, or
317
317
  /// nil if the last call succeeded. Surfaces FILE_NOT_FOUND /
318
- /// FILE_DISAPPEARED / IO_<NSError code> / UNEXPECTED so analytics can
319
- /// split the previously opaque "Failed to calculate SHA256" bucket
320
- /// (mixpanel: 91.3% of verifyPackage failures are Android; iOS shares
321
- /// the calculator and inherits the same blind spot for its 14 ASC +
322
- /// 2 verifyPackage Promise-destroyed cases).
318
+ /// FILE_DISAPPEARED / IO_<NSError code> so analytics can split the
319
+ /// previously opaque "Failed to calculate SHA256" bucket (mixpanel:
320
+ /// 91.3% of verifyPackage failures are Android; iOS shares the
321
+ /// calculator and inherits the same blind spot for its 14 ASC + 2
322
+ /// verifyPackage Promise-destroyed cases). Keep this list in sync
323
+ /// with the setSHA256Failure(...) call sites in calculateSHA256
324
+ /// below — Android's wider taxonomy (FILE_TRUNCATED / OOM /
325
+ /// UNEXPECTED_<class>) does not apply here because the iOS reader
326
+ /// surfaces every disk error as a single `IO_<NSError code>`.
323
327
  ///
324
328
  /// Note: 0-byte files are NOT treated as a failure. They hash to the
325
329
  /// well-known empty-content SHA256 and the caller's expected/actual
@@ -359,9 +363,15 @@ public class BundleUpdateStore: NSObject {
359
363
  var context = CC_SHA256_CTX()
360
364
  CC_SHA256_Init(&context)
361
365
  var threwError: Error?
362
- // Wrap reads in try/catch via NSException bridge: FileHandle.readData
363
- // can raise on read failure (NSFileHandleOperationException);
364
- // ObjCRuntime catches those when bridged through NSObject methods.
366
+ // safeRead routes reads through FileHandle.read(upToCount:) on
367
+ // iOS 13.4+ that variant surfaces disk failures as throwing
368
+ // NSError, which we catch here as Swift `Error`. On pre-13.4
369
+ // OS versions safeRead falls back to readData(ofLength:),
370
+ // which raises NSFileHandleOperationException; Swift cannot
371
+ // catch ObjC NSExceptions via try/catch, so on those legacy
372
+ // versions a read failure will still abort the process. We
373
+ // accept that on the floor since 13.4+ has been the deployment
374
+ // target for years.
365
375
  while autoreleasepool(invoking: {
366
376
  do {
367
377
  let data = try Self.safeRead(fileHandle: fileHandle, length: 8192)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-bundle-update",
3
- "version": "3.0.31",
3
+ "version": "3.0.32",
4
4
  "description": "react-native-bundle-update",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",