From 5dd6908b250e83fdc5f67cdb70768ec8971bad83 Mon Sep 17 00:00:00 2001 From: Changnam Hong Date: Wed, 20 Mar 2019 04:46:46 -0700 Subject: [PATCH] Fix RCTJavaScriptLoader loadBundleAtURL error case (#23837) Summary: Change the function called when an error is returned from the completionHandler of the `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)`. * AS-IS - `RCTLogError()` - This error method does not post any notification for users. So users cannot receive notification when `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)` complete with error.(i.e. bundleURL is is invalid but not nil, `http://1`, `http://localho:8081/index.bundle`) * TO-BE - `handleError(error:)` - Call this method will post notification for users when `completionHandler` fails with error. [iOS] [Fixed] - Change the function called when an error is returned from the completionHandler of the `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)`. Pull Request resolved: https://github.com/facebook/react-native/pull/23837 Differential Revision: D14538790 Pulled By: cpojer fbshipit-source-id: da3306904c0d8113d204edfaa0f9e2a23793981a --- React/CxxBridge/RCTCxxBridge.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index f69b7efa01e..d3ac53820c0 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -409,9 +409,10 @@ struct RCTInstanceCallback : public InstanceCallback { "server or have included a .jsbundle file in your application bundle."); onSourceLoad(error, nil); } else { + __weak RCTCxxBridge *weakSelf = self; [RCTJavaScriptLoader loadBundleAtURL:self.bundleURL onProgress:onProgress onComplete:^(NSError *error, RCTSource *source) { if (error) { - RCTLogError(@"Failed to load bundle(%@) with error:(%@ %@)", self.bundleURL, error.localizedDescription, error.localizedFailureReason); + [weakSelf handleError:error]; return; } onSourceLoad(error, source);