Skip to content

Commit 13992f9

Browse files
rickhanloniifacebook-github-bot
authored andcommitted
Reconnect to debugger after reload
Summary: This diff allows re-connecting to the debugger websocket after reloading so that if, for example, metro has restarted, we'll reconnect to allow for debugging. Previously you would need to kill the app and re-open it to re-register the debugger websocket. Changelog: [iOS] [Fixed] Reconnect to debugger websocket after metro is restarted. Reviewed By: motiz88 Differential Revision: D18820399 fbshipit-source-id: ddbfa4476e70a6313c877a050ef2d77c04d1657e
1 parent d9deee2 commit 13992f9

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

React/DevSupport/RCTInspectorDevServerHelper.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ + (RCTInspectorPackagerConnection *)connectWithBundleURL:(NSURL *)bundleURL
128128

129129
NSString *key = [inspectorURL absoluteString];
130130
RCTInspectorPackagerConnection *connection = socketConnections[key];
131-
if (!connection) {
131+
if (!connection || !connection.isConnected) {
132132
connection = [[RCTInspectorPackagerConnection alloc] initWithURL:inspectorURL];
133133
socketConnections[key] = connection;
134134
[connection connect];

React/Inspector/RCTInspectorPackagerConnection.h

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ typedef RCTBundleStatus *(^RCTBundleStatusProvider)(void);
2020
@interface RCTInspectorPackagerConnection : NSObject
2121
- (instancetype)initWithURL:(NSURL *)url;
2222

23+
- (bool)isConnected;
2324
- (void)connect;
2425
- (void)closeQuietly;
2526
- (void)sendEventToAllConnections:(NSString *)event;

React/Inspector/RCTInspectorPackagerConnection.m

+5
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ - (void)webSocket:(__unused RCTSRWebSocket *)webSocket didCloseWithCode:(__unuse
241241
}
242242
}
243243

244+
- (bool)isConnected
245+
{
246+
return _webSocket != nil;
247+
}
248+
244249
- (void)connect
245250
{
246251
if (_closed) {

0 commit comments

Comments
 (0)