Skip to content

Commit e0ece12

Browse files
Peter Arganyfacebook-github-bot
authored andcommitted
Fix duplicate Networking module bug
Summary: While investigating a bridgeless networking issue, I noticed something very peculiar. **Two** networking turbo modules are built and used in bridgeless mode. Upon debugging, I realized that each of them have a different `TurboModuleHolder`. The reason is the following: 1. In JS, the module's name is [Networking](https://fburl.com/diffusion/f2xu4wie) 2. In ObjC, we call the module "RCTNetworking" (examples in this diff) 3. Both scenarios end up creating the correct Turbo Module: [RCTNetworking](https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/Libraries/Network/RCTNetworking.mm?link_ref=search), but the `TurboModuleHolder` doesn't know that "RCTNetworking" and "Networking" are the same. Any other modules accessed this way will have the same issue. An alternative solution would be to tell `TurboModuleHolder` to strip the `RCT` suffix, which would solve the problem globally. RSNara thoughts? Changelog: [Internal] Reviewed By: RSNara Differential Revision: D25477044 fbshipit-source-id: 02219de578ef4d19e579110e4242883a30cefcd6
1 parent d8c84d3 commit e0ece12

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Libraries/Blob/RCTBlobManager.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ - (void)remove:(NSString *)blobId
140140

141141
RCT_EXPORT_METHOD(addNetworkingHandler)
142142
{
143-
RCTNetworking *const networking = _bridge ? _bridge.networking : [_turboModuleRegistry moduleForName:"RCTNetworking"];
143+
RCTNetworking *const networking = _bridge ? _bridge.networking : [_turboModuleRegistry moduleForName:"Networking"];
144144

145145
// TODO(T63516227): Why can methodQueue be nil here?
146146
// We don't want to do anything when methodQueue is nil.

Libraries/Image/RCTImageLoader.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request
646646
{
647647
// Check if networking module is available
648648
if (RCT_DEBUG && ![_bridge respondsToSelector:@selector(networking)]
649-
&& ![_turboModuleRegistry moduleForName:"RCTNetworking"]) {
649+
&& ![_turboModuleRegistry moduleForName:"Networking"]) {
650650
RCTLogError(@"No suitable image URL loader found for %@. You may need to "
651651
" import the RCTNetwork library in order to load images.",
652652
request.URL.absoluteString);
@@ -655,7 +655,7 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request
655655

656656
RCTNetworking *networking = [_bridge networking];
657657
if (!networking) {
658-
networking = [_turboModuleRegistry moduleForName:"RCTNetworking"];
658+
networking = [_turboModuleRegistry moduleForName:"Networking"];
659659
}
660660

661661
// Check if networking module can load image

0 commit comments

Comments
 (0)