expo-dev-launcher 58.0.14 → 58.0.15
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 +7 -0
- package/android/build.gradle +2 -2
- package/android/src/debug/java/expo/modules/devlauncher/DevLauncherController.kt +4 -0
- package/android/src/debug/java/expo/modules/devlauncher/compose/models/HomeViewModel.kt +4 -1
- package/android/src/debug/java/expo/modules/devlauncher/launcher/errors/DevLauncherUncaughtExceptionHandler.kt +7 -19
- package/android/src/debug/java/expo/modules/devlauncher/logs/DevLauncherRemoteLog.kt +1 -1
- package/android/src/debug/java/expo/modules/devlauncher/logs/DevLauncherRemoteLogManager.kt +34 -0
- package/android/src/debug/java/expo/modules/devlauncher/react/DevLauncherBridgelessDevSupportManager.kt +5 -0
- package/ios/Errors/EXDevLauncherErrorManager.swift +4 -0
- package/ios/Errors/EXDevLauncherUncaughtExceptionHandler.swift +1 -11
- package/ios/Logs/EXDevLauncherRemoteLogsManager.swift +39 -8
- package/ios/SwiftUI/DevLauncherViewModel.swift +1 -0
- package/ios/Tests/EXDevLauncherRemoteLogsManagerTests.swift +56 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- On Android, a failed app load and a native error in the running app now appear in the terminal that runs `npx expo start`, with the `Android` tag. Before, these errors were visible only on the device. Crash reports sent to the terminal now also have the `Android` tag. ([#51670](https://github.com/expo/expo/pull/51670) by [@alanjhughes](https://github.com/alanjhughes))
|
|
8
|
+
- On iOS, a failed app load now appears in the terminal that runs `npx expo start`, with the `iOS` tag. Before, the error was visible only on the device. Crash reports sent to the terminal now also have the `iOS` tag. ([#51669](https://github.com/expo/expo/pull/51669) by [@alanjhughes](https://github.com/alanjhughes))
|
|
9
|
+
|
|
3
10
|
## 58.0.14
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/android/build.gradle
CHANGED
|
@@ -24,13 +24,13 @@ expoModule {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
group = "host.exp.exponent"
|
|
27
|
-
version = "58.0.
|
|
27
|
+
version = "58.0.15"
|
|
28
28
|
|
|
29
29
|
android {
|
|
30
30
|
namespace "expo.modules.devlauncher"
|
|
31
31
|
defaultConfig {
|
|
32
32
|
versionCode 9
|
|
33
|
-
versionName "58.0.
|
|
33
|
+
versionName "58.0.15"
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
buildTypes {
|
|
@@ -19,6 +19,7 @@ import com.facebook.react.bridge.ReactContext
|
|
|
19
19
|
import com.facebook.react.modules.network.OkHttpClientProvider
|
|
20
20
|
import expo.modules.devlauncher.helpers.DevLauncherInstallationIDHelper
|
|
21
21
|
import expo.modules.devlauncher.helpers.DevLauncherMetadataHelper
|
|
22
|
+
import expo.modules.devlauncher.helpers.DevLauncherUrl
|
|
22
23
|
import expo.modules.devlauncher.helpers.getFieldInClassHierarchy
|
|
23
24
|
import expo.modules.devlauncher.helpers.hasEnabledFlag
|
|
24
25
|
import expo.modules.devlauncher.helpers.runBlockingOnMainThread
|
|
@@ -36,6 +37,7 @@ import expo.modules.devlauncher.launcher.errors.DevLauncherUncaughtExceptionHand
|
|
|
36
37
|
import expo.modules.devlauncher.launcher.loaders.DevLauncherAppLoader
|
|
37
38
|
import expo.modules.devlauncher.launcher.loaders.DevLauncherEmbeddedAppLoader
|
|
38
39
|
import expo.modules.devlauncher.launcher.loaders.createAppLoader
|
|
40
|
+
import expo.modules.devlauncher.logs.DevLauncherRemoteLogManager
|
|
39
41
|
import expo.modules.devlauncher.react.activitydelegates.DevLauncherReactActivityNOPDelegate
|
|
40
42
|
import expo.modules.devlauncher.react.activitydelegates.DevLauncherReactActivityRedirectDelegate
|
|
41
43
|
import expo.modules.devlauncher.services.DependencyInjection
|
|
@@ -334,6 +336,8 @@ class DevLauncherController private constructor(
|
|
|
334
336
|
pendingIntentRegistry.intent = Intent(intent).setData(launch.strippedUrl)
|
|
335
337
|
loadApp(uri, activityToBeInvalidated)
|
|
336
338
|
} catch (e: Throwable) {
|
|
339
|
+
val appUrl = DevLauncherUrl(uri).url
|
|
340
|
+
DevLauncherRemoteLogManager.reportError(httpClient, appUrl, "Failed to load app from $appUrl.", e)
|
|
337
341
|
DevLauncherErrorActivity.showFatalError(context, DevLauncherAppError(e.message, e))
|
|
338
342
|
}
|
|
339
343
|
}
|
|
@@ -14,6 +14,7 @@ import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
|
|
14
14
|
import expo.modules.devlauncher.DevLauncherController
|
|
15
15
|
import expo.modules.devlauncher.launcher.DevLauncherAppEntry
|
|
16
16
|
import expo.modules.devlauncher.launcher.errors.DevLauncherErrorInstance
|
|
17
|
+
import expo.modules.devlauncher.logs.DevLauncherRemoteLogManager
|
|
17
18
|
import expo.modules.devlauncher.services.ErrorRegistryService
|
|
18
19
|
import expo.modules.devlauncher.services.NsdPreferences
|
|
19
20
|
import expo.modules.devlauncher.services.PackagerInfo
|
|
@@ -143,8 +144,10 @@ class HomeViewModel : ViewModel(), DefaultLifecycleObserver {
|
|
|
143
144
|
try {
|
|
144
145
|
devLauncherController.loadApp(action.url.toUri(), mainActivity = null)
|
|
145
146
|
} catch (e: Exception) {
|
|
147
|
+
val message = e.message ?: "Unknown error"
|
|
148
|
+
DevLauncherRemoteLogManager.reportError(devLauncherController.httpClient, action.url.toUri(), message)
|
|
146
149
|
_state.value = _state.value.copy(
|
|
147
|
-
loadingError =
|
|
150
|
+
loadingError = message
|
|
148
151
|
)
|
|
149
152
|
}
|
|
150
153
|
}
|
|
@@ -108,27 +108,15 @@ class DevLauncherUncaughtExceptionHandler(
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
try {
|
|
111
|
-
val
|
|
112
|
-
|
|
113
|
-
.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
val devSupportManager = requireNotNull(controller.appHost.devSupportManager)
|
|
112
|
+
DevLauncherRemoteLogManager.reportError(
|
|
113
|
+
DevLauncherController.instance.httpClient,
|
|
114
|
+
Uri.parse(devSupportManager.sourceUrl),
|
|
115
|
+
"Your app just crashed. See the error below.",
|
|
116
|
+
exception
|
|
117
|
+
)
|
|
118
118
|
} catch (e: Throwable) {
|
|
119
119
|
Log.e("DevLauncher", "Couldn't send an exception to bundler. $e", e)
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
private fun getWebSocketUrl(): Uri {
|
|
124
|
-
// URL structure replicates
|
|
125
|
-
// https://github.com/facebook/react-native/blob/0.69-stable/Libraries/Utilities/HMRClient.js#L164
|
|
126
|
-
val devSupportManager = requireNotNull(controller.appHost.devSupportManager)
|
|
127
|
-
return Uri
|
|
128
|
-
.parse(devSupportManager.sourceUrl)
|
|
129
|
-
.buildUpon()
|
|
130
|
-
.path("hot")
|
|
131
|
-
.clearQuery()
|
|
132
|
-
.build()
|
|
133
|
-
}
|
|
134
122
|
}
|
|
@@ -11,7 +11,7 @@ import com.google.gson.annotations.Expose
|
|
|
11
11
|
internal data class DevLauncherRemoteLog(
|
|
12
12
|
val messages: List<String>,
|
|
13
13
|
@Expose val level: String = "error",
|
|
14
|
-
@Expose val mode: String = "
|
|
14
|
+
@Expose val mode: String = "android"
|
|
15
15
|
) {
|
|
16
16
|
/**
|
|
17
17
|
* `data` is an array whose members are simply concatenated with a space before printing to the
|
|
@@ -28,6 +28,40 @@ class DevLauncherRemoteLogManager(private val httpClient: OkHttpClient, private
|
|
|
28
28
|
webSocket.close(1000, null)
|
|
29
29
|
batch.clear()
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
companion object {
|
|
33
|
+
fun reportError(httpClient: OkHttpClient, serverUrl: Uri, message: String, throwable: Throwable? = null) {
|
|
34
|
+
val url = webSocketUrl(serverUrl) ?: return
|
|
35
|
+
DevLauncherRemoteLogManager(httpClient, url)
|
|
36
|
+
.apply {
|
|
37
|
+
deferError(message)
|
|
38
|
+
throwable?.let { deferError(it) }
|
|
39
|
+
}
|
|
40
|
+
.sendViaWebSocket()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fun webSocketUrl(serverUrl: Uri): Uri? {
|
|
44
|
+
// URL structure replicates
|
|
45
|
+
// https://github.com/facebook/react-native/blob/0.69-stable/Libraries/Utilities/HMRClient.js#L164
|
|
46
|
+
val host = serverUrl.host
|
|
47
|
+
if (host.isNullOrEmpty() || host == "u.expo.dev") {
|
|
48
|
+
return null
|
|
49
|
+
}
|
|
50
|
+
return serverUrl
|
|
51
|
+
.buildUpon()
|
|
52
|
+
.scheme(
|
|
53
|
+
if (serverUrl.scheme == "https") {
|
|
54
|
+
"wss"
|
|
55
|
+
} else {
|
|
56
|
+
"ws"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
.path("hot")
|
|
60
|
+
.clearQuery()
|
|
61
|
+
.fragment(null)
|
|
62
|
+
.build()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
31
65
|
}
|
|
32
66
|
|
|
33
67
|
internal fun Throwable.toRemoteLogString(): String {
|
|
@@ -2,6 +2,7 @@ package expo.modules.devlauncher.react
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.util.Log
|
|
5
|
+
import androidx.core.net.toUri
|
|
5
6
|
import com.facebook.react.devsupport.NonFinalBridgelessDevSupportManager
|
|
6
7
|
import com.facebook.react.devsupport.ReactInstanceDevHelper
|
|
7
8
|
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
|
|
@@ -11,6 +12,7 @@ import expo.modules.devlauncher.DevLauncherController
|
|
|
11
12
|
import expo.modules.devlauncher.helpers.injectDevServerHelper
|
|
12
13
|
import expo.modules.devlauncher.launcher.errors.DevLauncherAppError
|
|
13
14
|
import expo.modules.devlauncher.launcher.errors.DevLauncherErrorActivity
|
|
15
|
+
import expo.modules.devlauncher.logs.DevLauncherRemoteLogManager
|
|
14
16
|
|
|
15
17
|
class DevLauncherBridgelessDevSupportManager(
|
|
16
18
|
applicationContext: Context,
|
|
@@ -60,6 +62,9 @@ class DevLauncherBridgelessDevSupportManager(
|
|
|
60
62
|
return
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
controller?.let {
|
|
66
|
+
DevLauncherRemoteLogManager.reportError(it.httpClient, sourceUrl.toUri(), message ?: "Native error", e)
|
|
67
|
+
}
|
|
63
68
|
controller?.onAppLoadedWithError()
|
|
64
69
|
DevLauncherErrorActivity.showError(activity, DevLauncherAppError(message, e))
|
|
65
70
|
}
|
|
@@ -17,6 +17,10 @@ public class EXDevLauncherErrorManager: NSObject {
|
|
|
17
17
|
|
|
18
18
|
@objc
|
|
19
19
|
public func showError(_ error: EXDevLauncherAppError) {
|
|
20
|
+
if let serverUrl = controller?.appManifestURLWithFallback() {
|
|
21
|
+
EXDevLauncherRemoteLogsManager.reportError(error.message, toServerAt: serverUrl)
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
#if !os(macOS)
|
|
21
25
|
let launcherVC = controller?.currentWindow()?.rootViewController
|
|
22
26
|
#else
|
|
@@ -51,20 +51,10 @@ public class EXDevLauncherUncaughtExceptionHandler: NSObject {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
static func getWebSocketUrl(_ controller: EXDevLauncherController) -> URL? {
|
|
54
|
-
// URL structure replicates
|
|
55
|
-
// https://github.com/facebook/react-native/blob/0.69-stable/Libraries/Utilities/HMRClient.js#L164
|
|
56
|
-
// but URLSessionWebSocketTask will crash if the scheme is not `ws` or `wss`
|
|
57
54
|
guard let appUrl = controller.sourceUrl() else {
|
|
58
55
|
return nil
|
|
59
56
|
}
|
|
60
|
-
|
|
61
|
-
return nil
|
|
62
|
-
}
|
|
63
|
-
guard var components = URLComponents(url: socketUrl, resolvingAgainstBaseURL: true) else {
|
|
64
|
-
return nil
|
|
65
|
-
}
|
|
66
|
-
components.scheme = "ws"
|
|
67
|
-
return components.url
|
|
57
|
+
return EXDevLauncherRemoteLogsManager.webSocketUrl(forServerUrl: appUrl)
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
static func tryToSaveException(_ exception: NSException) {
|
|
@@ -17,18 +17,49 @@ class EXDevLauncherRemoteLogsManager {
|
|
|
17
17
|
batch.append(message)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
func
|
|
20
|
+
static func reportError(_ message: String, toServerAt serverUrl: URL) {
|
|
21
|
+
guard let url = webSocketUrl(forServerUrl: serverUrl) else {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
// `sendSync` blocks for up to 2 seconds when the dev server is unreachable.
|
|
25
|
+
DispatchQueue.global(qos: .utility).async {
|
|
26
|
+
let logsManager = EXDevLauncherRemoteLogsManager(withUrl: url)
|
|
27
|
+
logsManager.deferError(message: message)
|
|
28
|
+
logsManager.sendSync()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static func webSocketUrl(forServerUrl serverUrl: URL) -> URL? {
|
|
33
|
+
// URL structure replicates
|
|
34
|
+
// https://github.com/facebook/react-native/blob/0.69-stable/Libraries/Utilities/HMRClient.js#L164
|
|
35
|
+
// but URLSessionWebSocketTask will crash if the scheme is not `ws` or `wss`
|
|
36
|
+
guard let host = serverUrl.host, host != "u.expo.dev" else {
|
|
37
|
+
return nil
|
|
38
|
+
}
|
|
39
|
+
guard let socketUrl = URL(string: "hot", relativeTo: serverUrl),
|
|
40
|
+
var components = URLComponents(url: socketUrl, resolvingAgainstBaseURL: true) else {
|
|
41
|
+
return nil
|
|
42
|
+
}
|
|
43
|
+
components.scheme = serverUrl.scheme == "https" ? "wss" : "ws"
|
|
44
|
+
return components.url
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static func payload(message: String) -> [String: Any] {
|
|
21
48
|
// message format comes from
|
|
22
49
|
// https://github.com/facebook/react-native/blob/0.69-stable/Libraries/Utilities/HMRClient.js#L119-L134
|
|
23
|
-
|
|
50
|
+
return [
|
|
24
51
|
"type": "log",
|
|
25
52
|
"level": "error",
|
|
26
|
-
"mode": "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
"mode": "ios",
|
|
54
|
+
"data": [message]
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func sendSync() {
|
|
59
|
+
// `data` is an array whose members are simply concatenated with a space before printing to
|
|
60
|
+
// the console, so we join messages with a newline and send an array consisting of just a
|
|
61
|
+
// single item.
|
|
62
|
+
let messageJson = Self.payload(message: batch.joined(separator: "\n"))
|
|
32
63
|
guard let data = try? JSONSerialization.data(withJSONObject: messageJson, options: []) else {
|
|
33
64
|
batch.removeAll()
|
|
34
65
|
return
|
|
@@ -236,6 +236,7 @@ class DevLauncherViewModel: ObservableObject {
|
|
|
236
236
|
},
|
|
237
237
|
onError: { [weak self] error in
|
|
238
238
|
let message = DevLauncherLoadErrorMessage.message(for: error as NSError, url: url)
|
|
239
|
+
EXDevLauncherRemoteLogsManager.reportError(message, toServerAt: bundleUrl)
|
|
239
240
|
DispatchQueue.main.async {
|
|
240
241
|
self?.isLoadingServer = false
|
|
241
242
|
self?.showErrorAlert(message)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import Testing
|
|
5
|
+
|
|
6
|
+
@testable import EXDevLauncher
|
|
7
|
+
|
|
8
|
+
@Suite("EXDevLauncherRemoteLogsManager")
|
|
9
|
+
struct EXDevLauncherRemoteLogsManagerTests {
|
|
10
|
+
@Test
|
|
11
|
+
func `dev server URL maps to its hot socket`() {
|
|
12
|
+
let url = EXDevLauncherRemoteLogsManager.webSocketUrl(forServerUrl: URL(string: "http://192.168.1.5:8081")!)
|
|
13
|
+
|
|
14
|
+
#expect(url?.absoluteString == "ws://192.168.1.5:8081/hot")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Test
|
|
18
|
+
func `bundle URL path and query are dropped`() {
|
|
19
|
+
let url = EXDevLauncherRemoteLogsManager.webSocketUrl(
|
|
20
|
+
forServerUrl: URL(string: "http://localhost:8081/index.bundle?platform=ios&dev=true")!
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
#expect(url?.absoluteString == "ws://localhost:8081/hot")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Test
|
|
27
|
+
func `https tunnel uses a secure socket`() {
|
|
28
|
+
let url = EXDevLauncherRemoteLogsManager.webSocketUrl(forServerUrl: URL(string: "https://abc-anonymous-8081.exp.direct")!)
|
|
29
|
+
|
|
30
|
+
#expect(url?.absoluteString == "wss://abc-anonymous-8081.exp.direct/hot")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Test
|
|
34
|
+
func `EAS Update URL has no dev server`() {
|
|
35
|
+
let url = EXDevLauncherRemoteLogsManager.webSocketUrl(forServerUrl: URL(string: "https://u.expo.dev/abc?channel-name=main")!)
|
|
36
|
+
|
|
37
|
+
#expect(url == nil)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Test
|
|
41
|
+
func `file URL has no dev server`() {
|
|
42
|
+
let url = EXDevLauncherRemoteLogsManager.webSocketUrl(forServerUrl: URL(string: "file:///var/app/main.jsbundle")!)
|
|
43
|
+
|
|
44
|
+
#expect(url == nil)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Test
|
|
48
|
+
func `payload tags the log as iOS`() {
|
|
49
|
+
let payload = EXDevLauncherRemoteLogsManager.payload(message: "Failed to load app")
|
|
50
|
+
|
|
51
|
+
#expect(payload["type"] as? String == "log")
|
|
52
|
+
#expect(payload["level"] as? String == "error")
|
|
53
|
+
#expect(payload["mode"] as? String == "ios")
|
|
54
|
+
#expect(payload["data"] as? [String] == ["Failed to load app"])
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
CHANGED