From 108089e78028dec5d7dc78e7748a608936df6599 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 27 Mar 2026 08:28:58 -0700 Subject: [PATCH] Fix RCTImageLoader to call completion handler when networking is unavailable Summary: `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] Differential Revision: D98122553 --- packages/react-native/Libraries/Image/RCTImageLoader.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/Image/RCTImageLoader.mm b/packages/react-native/Libraries/Image/RCTImageLoader.mm index 9c2553d7ec52..5cba225f0164 100644 --- a/packages/react-native/Libraries/Image/RCTImageLoader.mm +++ b/packages/react-native/Libraries/Image/RCTImageLoader.mm @@ -714,17 +714,19 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request completionHandler { RCTNetworking *networking = [_moduleRegistry moduleForName:"Networking"]; - if (RCT_DEBUG && !networking) { + if (!networking) { RCTLogError( @"No suitable image URL loader found for %@. You may need to " " import the RCTNetwork library in order to load images.", request.URL.absoluteString); + completionHandler(RCTErrorWithMessage(@"RCTNetworking module is not available"), nil, nil); return NULL; } // Check if networking module can load image - if (RCT_DEBUG && ![networking canHandleRequest:request]) { + if (![networking canHandleRequest:request]) { RCTLogError(@"No suitable image URL loader found for %@", request.URL.absoluteString); + completionHandler(RCTErrorWithMessage(@"No suitable URL loader for request"), nil, nil); return NULL; }