Skip to content
Permalink
Browse files
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
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Dec 6, 2019
1 parent d9deee2 commit 13992f90e48fc11e0b7217ee6d9413f97c32268a
Showing 3 changed files with 7 additions and 1 deletion.
@@ -128,7 +128,7 @@ + (RCTInspectorPackagerConnection *)connectWithBundleURL:(NSURL *)bundleURL

NSString *key = [inspectorURL absoluteString];
RCTInspectorPackagerConnection *connection = socketConnections[key];
if (!connection) {
if (!connection || !connection.isConnected) {
connection = [[RCTInspectorPackagerConnection alloc] initWithURL:inspectorURL];
socketConnections[key] = connection;
[connection connect];
@@ -20,6 +20,7 @@ typedef RCTBundleStatus *(^RCTBundleStatusProvider)(void);
@interface RCTInspectorPackagerConnection : NSObject
- (instancetype)initWithURL:(NSURL *)url;

- (bool)isConnected;
- (void)connect;
- (void)closeQuietly;
- (void)sendEventToAllConnections:(NSString *)event;
@@ -241,6 +241,11 @@ - (void)webSocket:(__unused RCTSRWebSocket *)webSocket didCloseWithCode:(__unuse
}
}

- (bool)isConnected
{
return _webSocket != nil;
}

- (void)connect
{
if (_closed) {

0 comments on commit 13992f9

Please sign in to comment.