Skip to content

Commit

Permalink
Fix new debugger detection after #864 (#904)
Browse files Browse the repository at this point in the history
In #864 where we tried to address the debugger listing changes in RN 77
we accidently broke debugger connection on older versions of React
Native (in particular expo-router example app).

The reason is that we wrongly assumed that the existence of
`reactNative` field in the debugger listing is exclusive to the new
debugger entries while it still appears with old version of the debugger
and on older versions of React Native. As a consequence, older apps (and
expo-router in particular) may select a wrong runtime to connect to
(which in case of expo-router was the reanimated runtime).

In this PR we partially revert changes from #864 responsible for
filtering new debugger entries from debug endpoints list. Instead, for
RN 77 specifically we rely on a suffix "[C++ connection]" that has been
added to description field:
https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp#L167

We likely want to revisit this solution going forward, but for now this
PR will unblock the release.

### How Has This Been Tested: 
1. Test debugger on RN 77 example 
2. Test debugger on expo-router example
  • Loading branch information
kmagiera authored Jan 14, 2025
1 parent 9c10c17 commit 3613b0d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vscode-extension/src/project/metro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ export class Metro implements Disposable {
}

private filterNewDebuggerPages(listJson: CDPTargetDescription[]) {
return listJson.filter((page) => page.reactNative);
return listJson.filter(
(page) =>
page.reactNative &&
(page.title.startsWith("React Native Bridge") ||
page.description.endsWith("[C++ connection]"))
);
}

private async isActiveExpoGoAppRuntime(webSocketDebuggerUrl: string) {
Expand Down

0 comments on commit 3613b0d

Please sign in to comment.