diff --git a/Libraries/WebSocket/RCTWebSocketExecutor.m b/Libraries/WebSocket/RCTWebSocketExecutor.m index c5813bc5c..e84539a73 100644 --- a/Libraries/WebSocket/RCTWebSocketExecutor.m +++ b/Libraries/WebSocket/RCTWebSocketExecutor.m @@ -66,9 +66,9 @@ RCT_EXPORT_MODULE() [NSURLConnection connectionWithRequest:[NSURLRequest requestWithURL:startDevToolsURL] delegate:nil]; if (![self connectToProxy]) { - RCTLogError(@"Connection to %@ timed out. Are you running node proxy? If \ - you are running on the device, check if you have the right IP \ - address in `RCTWebSocketExecutor.m`.", _url); + RCTLogError(@"Connection to %@ timed out. Are you running node proxy? If " + "you are running on the device, check if you have the right IP " + "address in `RCTWebSocketExecutor.m`.", _url); [self invalidate]; return; } @@ -81,7 +81,7 @@ RCT_EXPORT_MODULE() } if (!runtimeIsReady) { RCTLogError(@"Runtime is not ready. Make sure Chrome is running and not " - "paused on a breakpoint or exception and try reloading again."); + "paused on a breakpoint or exception and try reloading again."); [self invalidate]; return; } @@ -125,7 +125,11 @@ RCT_EXPORT_MODULE() - (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error { - RCTLogError(@"WebSocket connection failed with error %@", error); + dispatch_semaphore_signal(_socketOpenSemaphore); + dispatch_async(dispatch_get_main_queue(), ^{ + // Give the setUp method an opportunity to report an error first + RCTLogError(@"WebSocket connection failed with error %@", error); + }); } - (void)sendMessage:(NSDictionary *)message waitForReply:(RCTWSMessageCallback)callback diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index ce9bfb763..8e00e93f7 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -585,7 +585,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR - (void)logMessage:(NSString *)message level:(NSString *)level { - if (RCT_DEBUG) { + if (RCT_DEBUG && [_javaScriptExecutor isValid]) { [self enqueueJSCall:@"RCTLog.logIfNoNativeHook" args:@[level, message]]; }