Skip to content

Commit 1691801

Browse files
RSNarafacebook-github-bot
authored andcommitted
Temp: Always report debug info on module not found error
Summary: The TurboModule interop layer causes a surge in "module not found" exceptions: T154044825. After D45102812, this exception **should** have included debug info. But, it didn't. ## Problems So, there are two problems: 1. No debug logs are getting printed. 2. In the TurboModule interop test group, global.RN$TurboInterop is false **for some reason.** This is **very** strange. ## Changes 1. **Always** print the debug logs. 2. Add more flag-related debug information to the "module not found" debug logs. This will help us validate whether global.RN$TurboInterop is truely false. ## Concerns > **Always** print the debug logs on Android. **Question:** Won't this be really expensive? This shouldn't be too expensive: There are about ~50 native module requires in Fb4a. So: (1) the exception message shouldn't grow to an unreasonable size, (2) we'll only use enough memory to store ~50 strings in the JS VM. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D46195117 fbshipit-source-id: 8215c7339d16a1adc063b674805063865d1f7ab6
1 parent 58ef9e9 commit 1691801

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/react-native/Libraries/TurboModule/TurboModuleRegistry.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ function isTurboModuleInteropEnabled() {
3030
return global.RN$TurboInterop === true;
3131
}
3232

33-
function shouldReportLoadedModules() {
34-
return isTurboModuleInteropEnabled();
33+
// TODO(154308585): Remove "module not found" debug info logging
34+
function shouldReportDebugInfo() {
35+
return true;
3536
}
3637

3738
// TODO(148943970): Consider reversing the lookup here:
@@ -41,7 +42,7 @@ function requireModule<T: TurboModule>(name: string): ?T {
4142
// Backward compatibility layer during migration.
4243
const legacyModule = NativeModules[name];
4344
if (legacyModule != null) {
44-
if (shouldReportLoadedModules()) {
45+
if (shouldReportDebugInfo()) {
4546
moduleLoadHistory.NativeModules.push(name);
4647
}
4748
return ((legacyModule: $FlowFixMe): T);
@@ -51,17 +52,16 @@ function requireModule<T: TurboModule>(name: string): ?T {
5152
if (turboModuleProxy != null) {
5253
const module: ?T = turboModuleProxy(name);
5354
if (module != null) {
54-
if (shouldReportLoadedModules()) {
55+
if (shouldReportDebugInfo()) {
5556
moduleLoadHistory.TurboModules.push(name);
5657
}
5758
return module;
5859
}
5960
}
6061

61-
if (shouldReportLoadedModules()) {
62+
if (shouldReportDebugInfo()) {
6263
moduleLoadHistory.NotFound.push(name);
6364
}
64-
6565
return null;
6666
}
6767

@@ -75,7 +75,12 @@ export function getEnforcing<T: TurboModule>(name: string): T {
7575
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` +
7676
'Verify that a module by this name is registered in the native binary.';
7777

78-
if (shouldReportLoadedModules()) {
78+
if (shouldReportDebugInfo()) {
79+
message += 'Bridgeless mode: ' + (isBridgeless() ? 'true' : 'false') + '. ';
80+
message +=
81+
'TurboModule interop: ' +
82+
(isTurboModuleInteropEnabled() ? 'true' : 'false') +
83+
'. ';
7984
message += 'Modules loaded: ' + JSON.stringify(moduleLoadHistory);
8085
}
8186

0 commit comments

Comments
 (0)