You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1df562c
Browse filesBrowse the repository at this point in the historyBrowse files
Fix stale packager connections on Android (re-land)
## Summary:
Re-lands #58971 (stale packager connections on Android), which #60318 reverted. Same connection fix, plus:
- `isValidHost` uses `Request.Builder.url(String)`, which OkHttp 3 and 4 both have. `toHttpUrlOrNull` exists only in OkHttp 4.
- Tests use `localhost`, so they have no hardcoded IP addresses.
For the importer: `DevServerHelperTest` needs a dependency on the `DeveloperSettings` interface.
## Changelog:
[ANDROID] [FIXED] - Close stale packager connections when the dev server changes
## Test Plan:
- CI
- on-device
Differential Revision: D135356300
Pull Request resolved: #60403
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/DevSupportHttpClient.kt
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/ReconnectingWebSocket.kt
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -77,16 +77,18 @@ public class ReconnectingWebSocket(
77
77
}
78
78
79
79
publicfuncloseQuietly() {
80
-
closed =true
81
-
closeWebSocketQuietly()
82
-
messageCallback =null
80
+
synchronized(this) {
81
+
closed =true
82
+
closeWebSocketQuietly()
83
+
messageCallback =null
84
+
}
83
85
84
86
connectionCallback?.onDisconnected()
85
87
}
86
88
87
89
privatefuncloseWebSocketQuietly() {
88
90
try {
89
-
webSocket?.close(1_000, "End of session")
91
+
webSocket?.close(CLOSE_NORMAL, CLOSE_REASON)
90
92
} catch (e:Exception) {
91
93
// swallow, no need to handle it here
92
94
}
@@ -100,6 +102,10 @@ public class ReconnectingWebSocket(
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/res/devsupport/values/strings.xml
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@
8
8
<stringname="catalyst_change_bundle_location_instructions"project="catalyst"translatable="false">You can connect either via USB (localhost - default) or Wifi. If you connect via USB and running with a physical device, make sure you:\n 1. Connect your device via USB\n 2. Set the bundle location to `localhost:8081`\n 3. Run this command in your terminal:\n      `%1$s`</string>
<stringname="catalyst_open_debugger_error"project="catalyst"translatable="false">Failed to open DevTools. Please check that the dev server is running and reload the app.</string>
0 commit comments