Skip to content

Commit

Permalink
Improve remote debugging LogBox message, cleanup unused openURL method
Browse files Browse the repository at this point in the history
Summary:
Some tidying up around remote JS debugging while testing. See also react-native-community/cli#2083.

Changelog: [Internal]

Differential Revision: D49499068

fbshipit-source-id: 2e3c0a0e059333b95fca8ffbc2537ec5f01384c1
  • Loading branch information
huntie authored and facebook-github-bot committed Sep 21, 2023
1 parent 5845599 commit 25d42ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ - (void)sendMessage:(NSDictionary<NSString *, id> *)message onReply:(RCTWSMessag

dispatch_async(_jsQueue, ^{
if (!self.valid) {
callback(RCTErrorWithMessage(@"Runtime is not ready for debugging. Make sure Metro is running."), nil);
callback(
RCTErrorWithMessage(
@"Runtime is not ready for debugging. Make sure Metro is running and the Remote Debugging browser window is open."),
nil);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
escapedDeviceName,
escapedAppName]];
}
static NSURL *getOpenUrlEndpoint(NSURL *bundleURL)
{
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/open-url", getServerHost(bundleURL)]];
}

@implementation RCTInspectorDevServerHelper

RCT_NOT_IMPLEMENTED(-(instancetype)init)
Expand All @@ -68,27 +65,6 @@ static void sendEventToAllConnections(NSString *event)
}
}

+ (void)openURL:(NSString *)url withBundleURL:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessage
{
NSURL *endpoint = getOpenUrlEndpoint(bundleURL);

NSDictionary *jsonBodyDict = @{@"url" : url};
NSData *jsonBodyData = [NSJSONSerialization dataWithJSONObject:jsonBodyDict options:kNilOptions error:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:endpoint];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:jsonBodyData];

[[[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(
__unused NSData *_Nullable data, __unused NSURLResponse *_Nullable response, NSError *_Nullable error) {
if (error != nullptr) {
RCTLogWarn(@"%@", errorMessage);
}
}] resume];
}

+ (void)openDebugger:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessage
{
NSString *appId = [[[NSBundle mainBundle] bundleIdentifier]
Expand Down

0 comments on commit 25d42ed

Please sign in to comment.