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 df64993
Browse filesBrowse the repository at this point in the historyBrowse files
DevServerHelper opened and closed the packager connection in separate
AsyncTasks on THREAD_POOL_EXECUTOR. A close could run before a pending
open, and repeated opens could create two clients. Changing the bundle
location from the dev menu also kept the old connection. In both cases,
the old dev server could still reload the app.
- Run openPackagerConnection and closePackagerConnection as tasks on one
single-threaded executor. Tasks run in call order, off the UI thread,
and only that thread uses packagerClient. The executor names its
thread ReactPackagerConnection and stops it after 30 seconds without
work.
- Remember the host of the open client. If an open finds a client for a
different host, close it and connect to the new host.
- Check clientId on the caller's thread. A failed init() still crashes
the app, as before; packagerClient stays null, so a later open can
retry.
- Change Bundle Location: close the packager connection before the
reload, as setBundleSource does. Trim the input, then reject a host
that OkHttp cannot parse in the connection URL and show a toast.
Before, an invalid host was saved without a check.
- ReconnectingWebSocket: change close state under the socket's monitor,
so no message handler starts after closeQuietly() returns. Close a
socket whose handshake finishes after closeQuietly() instead of
reporting it as connected.
- Add DevServerHelperTest, ReconnectingWebSocketTest and
DevSupportHttpClientTest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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