From b708ee9b4e9df14ce227db00767b4b8c53fb6211 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Mon, 18 Jul 2022 17:54:37 -0700 Subject: [PATCH] Log if bridgeless mode is enabled, when JS Module call fails Summary: Log whether bridgeless mode is enabled or not when calling into a JavaScript module method fails. We are seeing a surge of these crashes in MessageQueue.js bridgeless mode. This temporary log will help us drill down into the issue. Changelog: [Internal] Created from CodeHub with https://fburl.com/edit-in-codehub This should not mess with the sitevar overrides. These are the two diffs where we mapped the venice and bridge errors to the same mid: D36649249, D36649249. Reviewed By: fkgozali Differential Revision: D37898744 fbshipit-source-id: 0ab337c8c0d73bd70c4756a16b8ece8ba8730c47 --- Libraries/BatchedBridge/MessageQueue.js | 5 ++++- Libraries/BatchedBridge/__tests__/MessageQueue-test.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 2ae720810ac9e4..bfe3e0c082152b 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -408,9 +408,12 @@ class MessageQueue { const callableModuleNames = Object.keys(this._lazyCallableModules); const n = callableModuleNames.length; const callableModuleNameList = callableModuleNames.join(', '); + + // TODO(T122225939): Remove after investigation: Why are we getting to this line in bridgeless mode? + const isBridgelessMode = global.RN$Bridgeless === true ? 'true' : 'false'; invariant( false, - `Failed to call into JavaScript module method ${module}.${method}(). Module has not been registered as callable. Registered callable JavaScript modules (n = ${n}): ${callableModuleNameList}. + `Failed to call into JavaScript module method ${module}.${method}(). Module has not been registered as callable. Bridgeless Mode: ${isBridgelessMode}. Registered callable JavaScript modules (n = ${n}): ${callableModuleNameList}. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, ); } diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index c94f580a1cbf42..e80e024b6fedb9 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -108,7 +108,7 @@ describe('MessageQueue', function () { const unknownModule = 'UnknownModule', unknownMethod = 'UnknownMethod'; expect(() => queue.__callFunction(unknownModule, unknownMethod)).toThrow( - `Failed to call into JavaScript module method ${unknownModule}.${unknownMethod}(). Module has not been registered as callable. Registered callable JavaScript modules (n = 1): MessageQueueTestModule. + `Failed to call into JavaScript module method ${unknownModule}.${unknownMethod}(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 1): MessageQueueTestModule. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, ); });