From 7f7cc0a5445f9e707476b6eacaec45f13a253068 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 30 Mar 2026 02:58:31 -0700 Subject: [PATCH] Fix RCTImageLoader to call completion handler when networking is unavailable (#56255) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- 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 9c2553d7ec5..5cba225f016 100644 --- a/packages/react-native/Libraries/Image/RCTImageLoader.mm +++ b/packages/react-native/Libraries/Image/RCTImageLoader.mm @@ -714,17 +714,19 @@ static RCTImageLoaderCancellationBlock RCTLoadImageURLFromLoader( 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; }