From d0912ed0671f854bc219eeda8656d440b33a41f4 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sun, 6 Oct 2024 15:13:40 -0700 Subject: [PATCH] Fix global.__fetchSegment's error case (#46854) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46854 When segment fetch fails, it seems incorrect to call the callback twice: once with error, and once with null. This seems like a bug. Created from CodeHub with https://fburl.com/edit-in-codehub Changelog: [Internal] Reviewed By: yungsters Differential Revision: D63959015 fbshipit-source-id: f3ebb0f4732d99d91b5717a5bf193f44d957bde4 --- packages/react-native/Libraries/Core/setUpSegmentFetcher.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native/Libraries/Core/setUpSegmentFetcher.js b/packages/react-native/Libraries/Core/setUpSegmentFetcher.js index 2a7115c1d45..54d9e37a6a0 100644 --- a/packages/react-native/Libraries/Core/setUpSegmentFetcher.js +++ b/packages/react-native/Libraries/Core/setUpSegmentFetcher.js @@ -42,6 +42,7 @@ function __fetchSegment( const error = new Error(errorObject.message); (error: any).code = errorObject.code; // flowlint-line unclear-type: off callback(error); + return; } callback(null);