Skip to content

Commit a89005d

Browse files
motiz88facebook-github-bot
authored andcommitted
Don't inject synthetic Debugger.disable message in modern CDP backend (#42400)
Summary: Pull Request resolved: #42400 Changelog: [Internal] TSIA - iOS counterpart of D52040149 on Android. The overarching principle is that nothing outside of an Agent should be doing anything with the CDP message stream. Here we have a case of `RCTInspectorDevServerHelper` basically impersonating the CDP frontend in order to paper over an apparent lifetime management bug in the old backend; this gets in the way of implementing reloads natively so we disable it under the new backend. NOTE: I'm gating out both the call site in `RCTBridge` (to signal intent) *and* the actual body of `disableDebugger` (in case any out-of-tree code happens to be using this method). Reviewed By: voideanvalue Differential Revision: D50967799 fbshipit-source-id: 759718bf155b8b16c7db54ac2d2507bc71c93436
1 parent 26e33a5 commit a89005d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

packages/react-native/React/Base/RCTBridge.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,11 @@ - (RCTBridgeModuleDecorator *)bridgeModuleDecorator
279279
- (void)didReceiveReloadCommand
280280
{
281281
#if RCT_ENABLE_INSPECTOR
282-
// Disable debugger to resume the JsVM & avoid thread locks while reloading
283-
[RCTInspectorDevServerHelper disableDebugger];
282+
auto &inspectorFlags = facebook::react::jsinspector_modern::InspectorFlags::getInstance();
283+
if (!inspectorFlags.getEnableModernCDPRegistry()) {
284+
// Disable debugger to resume the JsVM & avoid thread locks while reloading
285+
[RCTInspectorDevServerHelper disableDebugger];
286+
}
284287
#endif
285288

286289
[[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self userInfo:nil];

packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ + (void)openDebugger:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessag
145145

146146
+ (void)disableDebugger
147147
{
148-
sendEventToAllConnections(kDebuggerMsgDisable);
148+
auto &inspectorFlags = facebook::react::jsinspector_modern::InspectorFlags::getInstance();
149+
if (!inspectorFlags.getEnableModernCDPRegistry()) {
150+
sendEventToAllConnections(kDebuggerMsgDisable);
151+
}
149152
}
150153

151154
+ (id<RCTInspectorPackagerConnectionProtocol>)connectWithBundleURL:(NSURL *)bundleURL

0 commit comments

Comments
 (0)