expo-updates 57.0.26 → 57.0.28
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/CHANGELOG.md +16 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/updates/UpdatesUtils.kt +47 -25
- package/android/src/main/java/expo/modules/updates/loader/FileDownloader.kt +72 -34
- package/android/src/main/java/expo/modules/updates/statemachine/UpdatesStateMachine.kt +7 -1
- package/ios/EXUpdates/UpdatesStateMachine.swift +6 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,22 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 57.0.28 — 2026-11-12
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Send download progress to JavaScript in 1% steps, so updates with many assets no longer use a large amount of memory while they download. ([#53250](https://github.com/expo/expo/pull/53250) by [@alanjhughes](https://github.com/alanjhughes))
|
|
18
|
+
|
|
19
|
+
## 57.0.27 — 2026-11-05
|
|
20
|
+
|
|
21
|
+
### 🐛 Bug fixes
|
|
22
|
+
|
|
23
|
+
- [Android] Fix a startup crash (`Compiling JS failed: Buffer is smaller than the size stated in the file header`) caused by a truncated update asset. Downloaded assets are now moved into place with an atomic rename after the hash is verified, instead of being stream-copied into the final path, and an asset file that already exists on disk is only reused when it matches the hash declared in the manifest. ([#51715](https://github.com/expo/expo/pull/51715) by [@AndreiCalazans](https://github.com/AndreiCalazans))
|
|
24
|
+
|
|
25
|
+
### 💡 Others
|
|
26
|
+
|
|
27
|
+
- Update `glob` to 14.0.3. ([#52819](https://github.com/expo/expo/pull/52819) by [@kitten](https://github.com/kitten))
|
|
28
|
+
|
|
13
29
|
## 57.0.26 — 2026-10-12
|
|
14
30
|
|
|
15
31
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -42,7 +42,7 @@ expoModule {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
group = 'host.exp.exponent'
|
|
45
|
-
version = '57.0.
|
|
45
|
+
version = '57.0.28'
|
|
46
46
|
|
|
47
47
|
// Utility method to derive boolean values from the environment or from Java properties,
|
|
48
48
|
// and return them as strings to be used in BuildConfig fields
|
|
@@ -94,7 +94,7 @@ android {
|
|
|
94
94
|
namespace "expo.modules.updates"
|
|
95
95
|
defaultConfig {
|
|
96
96
|
versionCode 31
|
|
97
|
-
versionName '57.0.
|
|
97
|
+
versionName '57.0.28'
|
|
98
98
|
consumerProguardFiles("proguard-rules.pro")
|
|
99
99
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
100
100
|
|
|
@@ -113,39 +113,61 @@ object UpdatesUtils {
|
|
|
113
113
|
@Throws(NoSuchAlgorithmException::class, IOException::class)
|
|
114
114
|
fun verifySHA256AndWriteToFile(inputStream: InputStream, destination: File, expectedBase64URLEncodedHash: String?): ByteArray {
|
|
115
115
|
DigestInputStream(inputStream, MessageDigest.getInstance("SHA-256")).use { digestInputStream ->
|
|
116
|
-
//
|
|
117
|
-
//
|
|
116
|
+
// Write to a temporary path first and only move the file into place after the hash is
|
|
117
|
+
// verified. The move is a rename on the same filesystem, so the destination is either absent
|
|
118
|
+
// or complete; it can never be observed partially written. A streamed copy into the
|
|
119
|
+
// destination (the previous implementation) left a truncated file behind when the process
|
|
120
|
+
// was killed mid-copy, and that file was later trusted because it existed.
|
|
118
121
|
val tmpFile = File(destination.absolutePath + ".tmp")
|
|
119
122
|
tmpFile.parentFile?.mkdirs()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
try {
|
|
124
|
+
digestInputStream.use { input ->
|
|
125
|
+
FileOutputStream(tmpFile).use { output ->
|
|
126
|
+
input.copyTo(output)
|
|
127
|
+
// flush to disk before the file becomes visible at the final path, so a reboot or
|
|
128
|
+
// power loss right after the move cannot leave a truncated file behind
|
|
129
|
+
output.fd.sync()
|
|
130
|
+
}
|
|
123
131
|
}
|
|
124
|
-
}
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
tmpFile.copyTo(destination, true)
|
|
140
|
-
} catch (e: NoSuchFileException) {
|
|
141
|
-
throw IOException("File download was successful, but temp file ${tmpFile.absolutePath} does not exist")
|
|
142
|
-
} catch (e: Exception) {
|
|
143
|
-
throw IOException("File download was successful, but an exception occurred: $e")
|
|
133
|
+
// this message digest must be read after the input stream has been consumed in order to get the hash correctly
|
|
134
|
+
val md = digestInputStream.messageDigest
|
|
135
|
+
val hash = md.digest()
|
|
136
|
+
val hashBase64String = toBase64Url(hash)
|
|
137
|
+
if (expectedBase64URLEncodedHash != null && expectedBase64URLEncodedHash != hashBase64String) {
|
|
138
|
+
throw IOException("File download was successful but base64url-encoded SHA-256 did not match expected; expected: $expectedBase64URLEncodedHash; actual: $hashBase64String")
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// if there are two assets with identical content, they will be written to the same file path,
|
|
142
|
+
// so we allow overwrites
|
|
143
|
+
moveFileAtomically(tmpFile, destination)
|
|
144
|
+
|
|
145
|
+
return hash
|
|
144
146
|
} finally {
|
|
145
147
|
tmpFile.delete()
|
|
146
148
|
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Moves [source] to [destination], replacing any existing file. The temp file and the destination
|
|
154
|
+
* live in the same directory, so `rename(2)` applies and the move is atomic. If the rename is
|
|
155
|
+
* rejected anyway (for example, the two paths end up on different mount points), fall back to a
|
|
156
|
+
* copy so the download still succeeds.
|
|
157
|
+
*/
|
|
158
|
+
@Throws(IOException::class)
|
|
159
|
+
internal fun moveFileAtomically(source: File, destination: File) {
|
|
160
|
+
if (!source.exists()) {
|
|
161
|
+
throw IOException("File download was successful, but temp file ${source.absolutePath} does not exist")
|
|
162
|
+
}
|
|
163
|
+
if (source.renameTo(destination)) {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
Log.w(TAG, "Atomic rename of ${source.absolutePath} to ${destination.absolutePath} failed; falling back to copy")
|
|
167
|
+
try {
|
|
168
|
+
source.copyTo(destination, true)
|
|
169
|
+
} catch (e: Exception) {
|
|
170
|
+
throw IOException("File download was successful, but an exception occurred: $e")
|
|
149
171
|
}
|
|
150
172
|
}
|
|
151
173
|
|
|
@@ -747,47 +747,85 @@ class FileDownloader(
|
|
|
747
747
|
val path = File(destinationDirectory, filename)
|
|
748
748
|
|
|
749
749
|
if (path.exists()) {
|
|
750
|
-
asset
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
750
|
+
if (isExistingAssetFileValid(path, asset, requestedUpdate)) {
|
|
751
|
+
asset.relativePath = filename
|
|
752
|
+
return AssetDownloadResult(asset, false)
|
|
753
|
+
}
|
|
754
|
+
// the file on disk is not the asset we expect (for example, it was truncated when a previous
|
|
755
|
+
// process was killed); throw it away and download again
|
|
756
|
+
path.delete()
|
|
757
|
+
}
|
|
758
758
|
|
|
759
|
-
|
|
760
|
-
|
|
759
|
+
val canApplyPatch =
|
|
760
|
+
asset.isLaunchAsset &&
|
|
761
|
+
launchedUpdate != null &&
|
|
762
|
+
requestedUpdate != null &&
|
|
763
|
+
launchedUpdate.id != requestedUpdate.id
|
|
764
|
+
|
|
765
|
+
try {
|
|
766
|
+
val downloadResult = downloadAssetAndVerifyHashAndWriteToPath(
|
|
767
|
+
asset,
|
|
768
|
+
extraHeaders,
|
|
769
|
+
createRequestForAsset(
|
|
761
770
|
asset,
|
|
762
771
|
extraHeaders,
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
requestedUpdate = requestedUpdate,
|
|
776
|
-
embeddedAssetExtractor = embeddedAssetExtractor
|
|
777
|
-
)
|
|
772
|
+
configuration,
|
|
773
|
+
allowPatch = canApplyPatch
|
|
774
|
+
),
|
|
775
|
+
asset.expectedHash,
|
|
776
|
+
path,
|
|
777
|
+
destinationDirectory,
|
|
778
|
+
assetLoadProgressListener?.let { listener -> { listener.invoke(it) } },
|
|
779
|
+
allowPatch = canApplyPatch,
|
|
780
|
+
launchedUpdate = launchedUpdate,
|
|
781
|
+
requestedUpdate = requestedUpdate,
|
|
782
|
+
embeddedAssetExtractor = embeddedAssetExtractor
|
|
783
|
+
)
|
|
778
784
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
785
|
+
asset.downloadTime = Date()
|
|
786
|
+
asset.relativePath = filename
|
|
787
|
+
asset.hash = downloadResult.hash
|
|
788
|
+
return AssetDownloadResult(asset, true)
|
|
789
|
+
} catch (e: Exception) {
|
|
790
|
+
val message = "Failed to download asset ${asset.key}"
|
|
791
|
+
logger.error(message, e, UpdatesErrorCode.AssetsFailedToLoad)
|
|
792
|
+
throw IOException(message, e)
|
|
788
793
|
}
|
|
789
794
|
}
|
|
790
795
|
|
|
796
|
+
/**
|
|
797
|
+
* An asset file that already exists on disk is only reused when its contents match the hash the
|
|
798
|
+
* manifest declares for the asset. Trusting the file because it exists is unsafe: a process
|
|
799
|
+
* killed while the file was being written leaves a truncated file behind, and the launch asset
|
|
800
|
+
* then fails to load with a Hermes `Buffer is smaller than the size stated in the file header`
|
|
801
|
+
* error. When the manifest has no hash for the asset there is nothing to verify against, so the
|
|
802
|
+
* file is reused as before.
|
|
803
|
+
*/
|
|
804
|
+
private fun isExistingAssetFileValid(path: File, asset: AssetEntity, requestedUpdate: UpdateEntity?): Boolean {
|
|
805
|
+
val expectedHash = asset.expectedHash ?: return true
|
|
806
|
+
val actualHash = try {
|
|
807
|
+
UpdatesUtils.toBase64Url(UpdatesUtils.sha256(path))
|
|
808
|
+
} catch (e: Exception) {
|
|
809
|
+
logger.warn(
|
|
810
|
+
"Failed to hash existing file for asset ${asset.key}; re-downloading: ${e.message}",
|
|
811
|
+
UpdatesErrorCode.AssetsFailedToLoad,
|
|
812
|
+
requestedUpdate?.id?.toString(),
|
|
813
|
+
asset.key
|
|
814
|
+
)
|
|
815
|
+
return false
|
|
816
|
+
}
|
|
817
|
+
if (actualHash == expectedHash) {
|
|
818
|
+
return true
|
|
819
|
+
}
|
|
820
|
+
logger.warn(
|
|
821
|
+
"Existing file for asset ${asset.key} did not match expected hash (size ${path.length()} bytes); re-downloading",
|
|
822
|
+
UpdatesErrorCode.AssetsFailedToLoad,
|
|
823
|
+
requestedUpdate?.id?.toString(),
|
|
824
|
+
asset.key
|
|
825
|
+
)
|
|
826
|
+
return false
|
|
827
|
+
}
|
|
828
|
+
|
|
791
829
|
private suspend fun downloadData(request: Request, progressListener: FileDownloadProgressListener? = null): Response =
|
|
792
830
|
suspendCancellableCoroutine { continuation ->
|
|
793
831
|
val call = client.newCall(request)
|
|
@@ -10,6 +10,7 @@ import expo.modules.updatesinterface.UpdatesControllerRegistry
|
|
|
10
10
|
import kotlinx.coroutines.CoroutineScope
|
|
11
11
|
import kotlinx.coroutines.Dispatchers
|
|
12
12
|
import java.util.Date
|
|
13
|
+
import kotlin.math.floor
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* The Updates state machine class. There should be only one instance of this class
|
|
@@ -92,6 +93,7 @@ class UpdatesStateMachine(
|
|
|
92
93
|
*/
|
|
93
94
|
private fun processEvent(event: UpdatesStateEvent) {
|
|
94
95
|
if (transition(event)) {
|
|
96
|
+
val previousProgress = context.downloadProgress
|
|
95
97
|
context = reduceContext(context, event)
|
|
96
98
|
if (event !is UpdatesStateEvent.DownloadProgress) {
|
|
97
99
|
logger.info("Updates state change: ${event.type}, context = ${context.json}")
|
|
@@ -104,7 +106,9 @@ class UpdatesStateMachine(
|
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
|
-
|
|
109
|
+
if (event !is UpdatesStateEvent.DownloadProgress || floor(context.downloadProgress * 100) != floor(previousProgress * 100)) {
|
|
110
|
+
sendContextToJS()
|
|
111
|
+
}
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
|
|
@@ -224,12 +228,14 @@ class UpdatesStateMachine(
|
|
|
224
228
|
isDownloading = false,
|
|
225
229
|
downloadError = null,
|
|
226
230
|
isUpdatePending = true,
|
|
231
|
+
downloadProgress = 1.0,
|
|
227
232
|
downloadStartTime = null,
|
|
228
233
|
downloadFinishTime = null
|
|
229
234
|
)
|
|
230
235
|
is UpdatesStateEvent.DownloadCompleteWithUpdate -> context.copyAndIncrementSequenceNumber(
|
|
231
236
|
isDownloading = false,
|
|
232
237
|
downloadError = null,
|
|
238
|
+
downloadProgress = 1.0,
|
|
233
239
|
latestManifest = event.manifest,
|
|
234
240
|
downloadedManifest = event.manifest,
|
|
235
241
|
rollback = null,
|
|
@@ -393,6 +393,7 @@ internal class UpdatesStateMachine {
|
|
|
393
393
|
private func processEvent(_ event: UpdatesStateEvent) {
|
|
394
394
|
// Execute state transition
|
|
395
395
|
if transition(event) {
|
|
396
|
+
let previousProgress = context.downloadProgress
|
|
396
397
|
// Only change context if transition succeeds
|
|
397
398
|
context = reducedContext(context, event)
|
|
398
399
|
if event.type != .downloadProgress {
|
|
@@ -406,7 +407,9 @@ internal class UpdatesStateMachine {
|
|
|
406
407
|
}
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
|
-
|
|
410
|
+
if event.type != .downloadProgress || (context.downloadProgress * 100).rounded(.down) != (previousProgress * 100).rounded(.down) {
|
|
411
|
+
sendContextToJS()
|
|
412
|
+
}
|
|
410
413
|
}
|
|
411
414
|
}
|
|
412
415
|
internal func processEventForTesting(_ event: UpdatesStateEvent) {
|
|
@@ -510,6 +513,7 @@ internal class UpdatesStateMachine {
|
|
|
510
513
|
$0.isDownloading = false
|
|
511
514
|
$0.downloadError = nil
|
|
512
515
|
$0.isUpdatePending = true
|
|
516
|
+
$0.downloadProgress = 1.0
|
|
513
517
|
$0.downloadStartTime = nil
|
|
514
518
|
$0.downloadFinishTime = nil
|
|
515
519
|
}
|
|
@@ -517,6 +521,7 @@ internal class UpdatesStateMachine {
|
|
|
517
521
|
return context.copyAndIncrementSequenceNumber {
|
|
518
522
|
$0.isDownloading = false
|
|
519
523
|
$0.downloadError = nil
|
|
524
|
+
$0.downloadProgress = 1.0
|
|
520
525
|
$0.latestManifest = manifest
|
|
521
526
|
$0.downloadedManifest = manifest
|
|
522
527
|
$0.rollback = nil
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-updates",
|
|
3
|
-
"version": "57.0.
|
|
3
|
+
"version": "57.0.28",
|
|
4
4
|
"description": "Fetches and manages remotely-hosted assets and updates to your app's JS bundle.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@expo/code-signing-certificates": "^0.0.6",
|
|
32
|
-
"@expo/plist": "^0.8.
|
|
32
|
+
"@expo/plist": "^0.8.2",
|
|
33
33
|
"@expo/spawn-async": "^1.8.0",
|
|
34
34
|
"arg": "^4.1.0",
|
|
35
35
|
"chalk": "^4.1.2",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"expo-structured-headers": "~57.0.1",
|
|
40
40
|
"expo-updates-interface": "~57.0.2",
|
|
41
41
|
"getenv": "^2.0.0",
|
|
42
|
-
"glob": "^
|
|
42
|
+
"glob": "^14.0.3",
|
|
43
43
|
"ignore": "^5.3.1",
|
|
44
44
|
"nullthrows": "^1.1.1",
|
|
45
45
|
"resolve-from": "^5.0.0"
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"picomatch": "^4.0.4",
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
62
|
"xstate": "^4.37.2",
|
|
63
|
-
"@expo/metro-config": "57.0.
|
|
64
|
-
"expo": "57.0.
|
|
65
|
-
"expo
|
|
63
|
+
"@expo/metro-config": "57.0.14",
|
|
64
|
+
"expo-dev-client": "57.0.21",
|
|
65
|
+
"expo": "57.0.33",
|
|
66
66
|
"expo-module-scripts": "56.0.3"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"./scripts/with-node.sh"
|
|
83
83
|
]
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "968a9dcec304789b2ccc1a41ef5d301938e91478",
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build": "expo-module build",
|
|
88
88
|
"clean": "expo-module clean",
|