Skip to content

Commit 7f7cc0a

Browse files
javachemeta-codesync[bot]
authored andcommitted
Fix RCTImageLoader to call completion handler when networking is unavailable (#56255)
Summary: Pull Request resolved: #56255 `RCTImageLoader._loadURLRequest:` returned NULL without calling the completion handler when the `RCTNetworking` module was unavailable. This left `dispatch_group_wait` in `RCTSyncImageManager` blocking for the full 20-second timeout per image. Additionally, the checks were guarded by `RCT_DEBUG`, meaning they only ran in debug builds. Remove the `RCT_DEBUG` guard so the error path runs in all builds. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D98122553 fbshipit-source-id: 5d0216cb527734094b44df4f3918c2d6fe79b3e2
1 parent bd46bca commit 7f7cc0a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/react-native/Libraries/Image/RCTImageLoader.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,17 +714,19 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request
714714
completionHandler
715715
{
716716
RCTNetworking *networking = [_moduleRegistry moduleForName:"Networking"];
717-
if (RCT_DEBUG && !networking) {
717+
if (!networking) {
718718
RCTLogError(
719719
@"No suitable image URL loader found for %@. You may need to "
720720
" import the RCTNetwork library in order to load images.",
721721
request.URL.absoluteString);
722+
completionHandler(RCTErrorWithMessage(@"RCTNetworking module is not available"), nil, nil);
722723
return NULL;
723724
}
724725

725726
// Check if networking module can load image
726-
if (RCT_DEBUG && ![networking canHandleRequest:request]) {
727+
if (![networking canHandleRequest:request]) {
727728
RCTLogError(@"No suitable image URL loader found for %@", request.URL.absoluteString);
729+
completionHandler(RCTErrorWithMessage(@"No suitable URL loader for request"), nil, nil);
728730
return NULL;
729731
}
730732

0 commit comments

Comments
 (0)