diff --git a/change/react-native-windows-43607961-c50e-495c-9c7a-1369930f4120.json b/change/react-native-windows-43607961-c50e-495c-9c7a-1369930f4120.json new file mode 100644 index 00000000000..ca6da16bc5b --- /dev/null +++ b/change/react-native-windows-43607961-c50e-495c-9c7a-1369930f4120.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Attempt AddNetworkingHandler if HTTP module was not ready (#11926)", + "packageName": "react-native-windows", + "email": "julio.rocha@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Desktop.IntegrationTests/RNTesterIntegrationTests.cpp b/vnext/Desktop.IntegrationTests/RNTesterIntegrationTests.cpp index 5a4e3e46ba3..b9f3886dc94 100644 --- a/vnext/Desktop.IntegrationTests/RNTesterIntegrationTests.cpp +++ b/vnext/Desktop.IntegrationTests/RNTesterIntegrationTests.cpp @@ -26,7 +26,6 @@ TEST_MODULE_INITIALIZE(InitModule) { using Microsoft::React::SetRuntimeOptionBool; SetRuntimeOptionBool("WebSocket.AcceptSelfSigned", true); - SetRuntimeOptionBool("Blob.EnableModule", true); // WebSocketJSExecutor can't register native log hooks. SetRuntimeOptionBool("RNTester.UseWebDebugger", false); diff --git a/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json b/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json index b25b3921ce7..af953654219 100644 --- a/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json +++ b/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json @@ -26,15 +26,6 @@ "NETStandard.Library": "2.0.3" } }, - "Microsoft.UI.Xaml": { - "type": "Direct", - "requested": "[2.8.0, )", - "resolved": "2.8.0", - "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", - "dependencies": { - "Microsoft.Web.WebView2": "1.0.1264.42" - } - }, "MSTest.TestAdapter": { "type": "Direct", "requested": "[2.2.10, )", @@ -53,6 +44,16 @@ "resolved": "13.0.1", "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, + "boost": { + "type": "Transitive", + "resolved": "1.76.0", + "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" + }, + "Microsoft.JavaScript.Hermes": { + "type": "Transitive", + "resolved": "0.1.15", + "contentHash": "My/u5RvxoymtwWokoweU6iVpuP79w271UjadcmSNqnQ9ESIv00tlVP4sHnIiN3t2lJNDeciyE1EVF4swGPECKQ==" + }, "Microsoft.Net.Native.Compiler": { "type": "Transitive", "resolved": "2.2.7-rel-27913-00", @@ -77,22 +78,35 @@ "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "2.1.0", - "contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==" + "contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ==" }, "Microsoft.NETCore.Targets": { "type": "Transitive", "resolved": "1.0.1", "contentHash": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw==" }, + "Microsoft.UI.Xaml": { + "type": "Transitive", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" }, + "Microsoft.Windows.SDK.BuildTools": { + "type": "Transitive", + "resolved": "10.0.22000.194", + "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg==" + }, "NETStandard.Library": { "type": "Transitive", "resolved": "2.0.3", - "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==", "dependencies": { "Microsoft.NETCore.Platforms": "1.1.0" } @@ -292,6 +306,7 @@ "folly": { "type": "Project", "dependencies": { + "boost": "[1.76.0, )", "fmt": "[1.0.0, )" } }, @@ -300,7 +315,11 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "ReactCommon": "[1.0.0, )" + "Microsoft.JavaScript.Hermes": "[0.1.15, )", + "Microsoft.UI.Xaml": "[2.8.0, )", + "Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )", + "ReactCommon": "[1.0.0, )", + "boost": "[1.76.0, )" } }, "microsoft.reactnative.managed": { @@ -313,7 +332,8 @@ "reactcommon": { "type": "Project", "dependencies": { - "Folly": "[1.0.0, )" + "Folly": "[1.0.0, )", + "boost": "[1.76.0, )" } } }, diff --git a/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json b/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json index b25b3921ce7..af953654219 100644 --- a/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json +++ b/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json @@ -26,15 +26,6 @@ "NETStandard.Library": "2.0.3" } }, - "Microsoft.UI.Xaml": { - "type": "Direct", - "requested": "[2.8.0, )", - "resolved": "2.8.0", - "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", - "dependencies": { - "Microsoft.Web.WebView2": "1.0.1264.42" - } - }, "MSTest.TestAdapter": { "type": "Direct", "requested": "[2.2.10, )", @@ -53,6 +44,16 @@ "resolved": "13.0.1", "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, + "boost": { + "type": "Transitive", + "resolved": "1.76.0", + "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" + }, + "Microsoft.JavaScript.Hermes": { + "type": "Transitive", + "resolved": "0.1.15", + "contentHash": "My/u5RvxoymtwWokoweU6iVpuP79w271UjadcmSNqnQ9ESIv00tlVP4sHnIiN3t2lJNDeciyE1EVF4swGPECKQ==" + }, "Microsoft.Net.Native.Compiler": { "type": "Transitive", "resolved": "2.2.7-rel-27913-00", @@ -77,22 +78,35 @@ "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "2.1.0", - "contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==" + "contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ==" }, "Microsoft.NETCore.Targets": { "type": "Transitive", "resolved": "1.0.1", "contentHash": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw==" }, + "Microsoft.UI.Xaml": { + "type": "Transitive", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } + }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" }, + "Microsoft.Windows.SDK.BuildTools": { + "type": "Transitive", + "resolved": "10.0.22000.194", + "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg==" + }, "NETStandard.Library": { "type": "Transitive", "resolved": "2.0.3", - "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==", "dependencies": { "Microsoft.NETCore.Platforms": "1.1.0" } @@ -292,6 +306,7 @@ "folly": { "type": "Project", "dependencies": { + "boost": "[1.76.0, )", "fmt": "[1.0.0, )" } }, @@ -300,7 +315,11 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "ReactCommon": "[1.0.0, )" + "Microsoft.JavaScript.Hermes": "[0.1.15, )", + "Microsoft.UI.Xaml": "[2.8.0, )", + "Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )", + "ReactCommon": "[1.0.0, )", + "boost": "[1.76.0, )" } }, "microsoft.reactnative.managed": { @@ -313,7 +332,8 @@ "reactcommon": { "type": "Project", "dependencies": { - "Folly": "[1.0.0, )" + "Folly": "[1.0.0, )", + "boost": "[1.76.0, )" } } }, diff --git a/vnext/Microsoft.ReactNative.Managed/packages.lock.json b/vnext/Microsoft.ReactNative.Managed/packages.lock.json index 2750d3ec05d..e4fc0a3a896 100644 --- a/vnext/Microsoft.ReactNative.Managed/packages.lock.json +++ b/vnext/Microsoft.ReactNative.Managed/packages.lock.json @@ -24,11 +24,21 @@ "Microsoft.SourceLink.Common": "1.0.0" } }, + "boost": { + "type": "Transitive", + "resolved": "1.76.0", + "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" + }, "Microsoft.Build.Tasks.Git": { "type": "Transitive", "resolved": "1.0.0", "contentHash": "z2fpmmt+1Jfl+ZnBki9nSP08S1/tbEOxFdsK1rSR+LBehIJz1Xv9/6qOOoGNqlwnAGGVGis1Oj6S8Kt9COEYlQ==" }, + "Microsoft.JavaScript.Hermes": { + "type": "Transitive", + "resolved": "0.1.15", + "contentHash": "My/u5RvxoymtwWokoweU6iVpuP79w271UjadcmSNqnQ9ESIv00tlVP4sHnIiN3t2lJNDeciyE1EVF4swGPECKQ==" + }, "Microsoft.Net.Native.Compiler": { "type": "Transitive", "resolved": "2.2.7-rel-27913-00", @@ -53,17 +63,35 @@ "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "2.1.0", - "contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==" + "contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ==" }, "Microsoft.SourceLink.Common": { "type": "Transitive", "resolved": "1.0.0", "contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg==" }, + "Microsoft.UI.Xaml": { + "type": "Transitive", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, + "Microsoft.Windows.SDK.BuildTools": { + "type": "Transitive", + "resolved": "10.0.22000.194", + "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg==" + }, "NETStandard.Library": { "type": "Transitive", "resolved": "2.0.3", - "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==", "dependencies": { "Microsoft.NETCore.Platforms": "1.1.0" } @@ -144,6 +172,7 @@ "folly": { "type": "Project", "dependencies": { + "boost": "[1.76.0, )", "fmt": "[1.0.0, )" } }, @@ -152,13 +181,18 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "ReactCommon": "[1.0.0, )" + "Microsoft.JavaScript.Hermes": "[0.1.15, )", + "Microsoft.UI.Xaml": "[2.8.0, )", + "Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )", + "ReactCommon": "[1.0.0, )", + "boost": "[1.76.0, )" } }, "reactcommon": { "type": "Project", "dependencies": { - "Folly": "[1.0.0, )" + "Folly": "[1.0.0, )", + "boost": "[1.76.0, )" } } }, @@ -176,6 +210,11 @@ "runtime.win10-arm.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-arm.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", @@ -196,6 +235,11 @@ "runtime.win10-arm-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-arm-aot.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", @@ -216,6 +260,11 @@ "runtime.win10-arm64-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-arm64-aot.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", @@ -236,6 +285,11 @@ "runtime.win10-x64.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-x64.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", @@ -256,6 +310,11 @@ "runtime.win10-x64-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-x64-aot.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", @@ -276,6 +335,11 @@ "runtime.win10-x86.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-x86.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", @@ -296,6 +360,11 @@ "runtime.win10-x86-aot.Microsoft.NETCore.UniversalWindowsPlatform": "6.2.9" } }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.1264.42", + "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" + }, "runtime.win10-x86-aot.Microsoft.NETCore.UniversalWindowsPlatform": { "type": "Transitive", "resolved": "6.2.9", diff --git a/vnext/Shared/Modules/HttpModule.cpp b/vnext/Shared/Modules/HttpModule.cpp index f3941b31e40..d94e3a16ea9 100644 --- a/vnext/Shared/Modules/HttpModule.cpp +++ b/vnext/Shared/Modules/HttpModule.cpp @@ -237,6 +237,8 @@ std::map HttpModule::getConstants() { // clang-format off std::vector HttpModule::getMethods() { + // See CxxNativeModule::lazyInit() + SetUpHttpResource(m_resource, getInstance(), m_inspectableProperties); return { @@ -249,12 +251,6 @@ std::vector HttpModule::getMethods() return; } - auto resource = holder->Module->m_resource; - if (!holder->Module->m_isResourceSetup) - { - SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties); - holder->Module->m_isResourceSetup = true; - } holder->Module->m_requestId++; auto params = facebook::xplat::jsArgAsObject(args, 0); @@ -263,7 +259,7 @@ std::vector HttpModule::getMethods() headers.emplace(header.first.getString(), header.second.getString()); } - resource->SendRequest( + holder->Module->m_resource->SendRequest( params["method"].asString(), params["url"].asString(), holder->Module->m_requestId, @@ -289,14 +285,7 @@ std::vector HttpModule::getMethods() return; } - auto resource = holder->Module->m_resource; - if (!holder->Module->m_isResourceSetup) - { - SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties); - holder->Module->m_isResourceSetup = true; - } - - resource->AbortRequest(facebook::xplat::jsArgAsInt(args, 0)); + holder->Module->m_resource->AbortRequest(facebook::xplat::jsArgAsInt(args, 0)); } }, { @@ -309,14 +298,7 @@ std::vector HttpModule::getMethods() return; } - auto resource = holder->Module->m_resource; - if (!holder->Module->m_isResourceSetup) - { - SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties); - holder->Module->m_isResourceSetup = true; - } - - resource->ClearCookies(); + holder->Module->m_resource->ClearCookies(); } } }; @@ -331,6 +313,11 @@ std::vector HttpModule::getMethods() return s_moduleName; } +/*extern*/ std::unique_ptr CreateHttpModule( + IInspectable const &inspectableProperties) noexcept { + return std::make_unique(inspectableProperties); +} + /*extern*/ const wchar_t *GetHttpTurboModuleName() noexcept { return s_moduleNameW; } diff --git a/vnext/Shared/Modules/HttpModule.h b/vnext/Shared/Modules/HttpModule.h index 94c5ca2032b..03b4da7f1af 100644 --- a/vnext/Shared/Modules/HttpModule.h +++ b/vnext/Shared/Modules/HttpModule.h @@ -84,7 +84,6 @@ class HttpModule : public facebook::xplat::module::CxxModule { std::shared_ptr m_resource; std::shared_ptr m_holder; - bool m_isResourceSetup{false}; int64_t m_requestId{0}; // Property bag high level reference. diff --git a/vnext/Shared/Networking/DefaultBlobResource.cpp b/vnext/Shared/Networking/DefaultBlobResource.cpp index 5f08a0240fc..eccf0357b4c 100644 --- a/vnext/Shared/Networking/DefaultBlobResource.cpp +++ b/vnext/Shared/Networking/DefaultBlobResource.cpp @@ -145,8 +145,13 @@ void DefaultBlobResource::AddNetworkingHandler() noexcept /*override*/ { httpHandler->AddRequestBodyHandler(m_requestBodyHandler); httpHandler->AddResponseHandler(m_responseHandler); } + } else { + // #11439 - The absence of HttpModule.Proxy may be caused by a module initialization race condition. + // Best-effort approach to set up the request/response handlers by exposing this interface to dependents + // (i.e. IHttpResource). + auto propId = msrn::ReactPropertyId>>{L"Blob.Resource"}; + m_propertyBag.Set(propId, weak_ptr(shared_from_this())); } - // TODO: else emit error? } void DefaultBlobResource::AddWebSocketHandler(int64_t id) noexcept /*override*/ { diff --git a/vnext/Shared/Networking/WinRTHttpResource.cpp b/vnext/Shared/Networking/WinRTHttpResource.cpp index 8ff56421dc8..07d36cf2afa 100644 --- a/vnext/Shared/Networking/WinRTHttpResource.cpp +++ b/vnext/Shared/Networking/WinRTHttpResource.cpp @@ -6,6 +6,7 @@ #include "WinRTHttpResource.h" #include +#include #include #include #include @@ -672,6 +673,14 @@ void WinRTHttpResource::AddResponseHandler(shared_ptr response auto propBag = ReactPropertyBag{inspectableProperties.try_as()}; auto moduleProxy = weak_ptr{result}; propBag.Set(propId, std::move(moduleProxy)); + + // #11439 - Best-effort attempt to set up the HTTP handler after an initial call to addNetworkingHandler failed. + auto blobRcPropId = ReactPropertyId>>{L"Blob.Resource"}; + if (auto prop = propBag.Get(blobRcPropId)) { + if (auto blobRc = prop.Value().lock()) { + blobRc->AddNetworkingHandler(); + } + } } return result; diff --git a/vnext/Shared/OInstance.cpp b/vnext/Shared/OInstance.cpp index 86453adc6a1..9c272645cd6 100644 --- a/vnext/Shared/OInstance.cpp +++ b/vnext/Shared/OInstance.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -68,15 +67,6 @@ using namespace Microsoft::JSI; using std::make_shared; using winrt::Microsoft::ReactNative::ReactPropertyBagHelper; -namespace Microsoft::React { - -/*extern*/ std::unique_ptr CreateHttpModule( - winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept { - return std::make_unique(inspectableProperties); -} - -} // namespace Microsoft::React - namespace facebook { namespace react { @@ -543,6 +533,10 @@ std::vector> InstanceImpl::GetDefaultNativeModules std::vector> modules; auto transitionalProps{ReactPropertyBagHelper::CreatePropertyBag()}; + // These modules are instantiated separately in MSRN (Universal Windows). + // When there are module name collisions, the last one registered is used. + // If this code is enabled, we will have unused module instances. + // Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable. #if (defined(_MSC_VER) && !defined(WINRT)) modules.push_back(std::make_unique( m_innerInstance, @@ -551,7 +545,6 @@ std::vector> InstanceImpl::GetDefaultNativeModules return Microsoft::React::CreateHttpModule(transitionalProps); }, nativeQueue)); -#endif modules.push_back(std::make_unique( m_innerInstance, @@ -561,11 +554,18 @@ std::vector> InstanceImpl::GetDefaultNativeModules }, nativeQueue)); - // TODO: This is not included for UWP because we have a different module which - // is added later. However, this one is designed - // so that we can base a UWP version on it. We need to do that but is not high - // priority. -#if (defined(_MSC_VER) && !defined(WINRT)) + modules.push_back(std::make_unique( + m_innerInstance, + Microsoft::React::GetBlobModuleName(), + [transitionalProps]() { return Microsoft::React::CreateBlobModule(transitionalProps); }, + nativeQueue)); + + modules.push_back(std::make_unique( + m_innerInstance, + Microsoft::React::GetFileReaderModuleName(), + [transitionalProps]() { return Microsoft::React::CreateFileReaderModule(transitionalProps); }, + nativeQueue)); + modules.push_back(std::make_unique( m_innerInstance, "Timing", @@ -620,26 +620,6 @@ std::vector> InstanceImpl::GetDefaultNativeModules []() { return std::make_unique(); }, nativeQueue)); - // These modules are instantiated separately in MSRN (Universal Windows). - // When there are module name colisions, the last one registered is used. - // If this code is enabled, we will have unused module instances. - // Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable. -#if (defined(_MSC_VER) && !defined(WINRT)) - if (Microsoft::React::GetRuntimeOptionBool("Blob.EnableModule")) { - modules.push_back(std::make_unique( - m_innerInstance, - Microsoft::React::GetBlobModuleName(), - [transitionalProps]() { return Microsoft::React::CreateBlobModule(transitionalProps); }, - nativeQueue)); - - modules.push_back(std::make_unique( - m_innerInstance, - Microsoft::React::GetFileReaderModuleName(), - [transitionalProps]() { return Microsoft::React::CreateFileReaderModule(transitionalProps); }, - nativeQueue)); - } -#endif - return modules; }