react-native: 0.72.2 Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome.
Description
After update to 0.72.2 and connect to chrome debugger an error appears:
Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome. Consider providing alternative methods to expose this method in debug mode, e.g. by exposing constants ahead-of-time.
React Native Version
0.72.2
Output of npx react-native info
System: OS: macOS 13.4.1 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Memory: 2.95 GB / 16.00 GB Shell: version: “5.9” path: /bin/zsh Binaries: Node: version: 16.13.0 path: /usr/local/bin/node Yarn: version: 3.2.1 path: /usr/local/bin/yarn npm: version: 8.1.0 path: /usr/local/bin/npm Watchman: version: 2022.10.24.00 path: /usr/local/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: - DriverKit 21.4 - iOS 16.0 - macOS 12.3 - tvOS 16.0 - watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: version: 14.0.1/14A400 path: /usr/bin/xcodebuild Languages: Java: version: 11.0.11 path: /usr/bin/javac Ruby: version: 2.6.5 path: /Users/user/.rvm/rubies/ruby-2.6.5/bin/ruby npmPackages: “@react-native-community/cli”: Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.2 wanted: 0.72.2 react-native-macos: Not Found npmGlobalPackages: “react-native”: Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: false newArchEnabled: false
Steps to reproduce
- start project
- connect to chrome debugger
Snack, code example, screenshot, or link to a repository
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 20
- Comments: 31
Is there any way to remove this red warning?
Edit: Following this answer, I changed
callNativeSyncHook
in the filenode_modules/react-native/Libraries/BatchedBridge/MessageQueue.js
like this:and saved it with patch-package. This seems to have fixed all error messages.
Ran into it as well, but the docs state remote debugging in Chrome is deprecated since 0.72
Copy pasting from the docs:
Haven’t tried it myself but hope this helps
Also got below error in console
@lazaro-contato The problem with Flipper is that last year, in their 2022 survey, RN team said that flipper wasn’t the right tool anymore and that they were working on better debugging tools “that meets our standard”
So flipper isn’t the right tool (it’s sad because it was promising, having native debug tools like logcat, etc. alongside with react and js devtools is a great idea, but it’s so heavy and buggy that I must agree with the RN team on this point). But in the same time chrome debugging is suffering from this bug since months with apparently no intention from the team to work on it.
I hope the new debug tools will arrive very soon, debugging XP in RN is such a major pain point
Edit: with react native debugger, the error still shows-up in devtools console but apparently not in the in-app Logbox. A little less annoying 😅
same in RN 0.72.6
Replicated on fresh install of RN 72.3, but app seems to run okay after throwing error.
I try this and it succeeds.No error msg! Thanks bro!
that doesn’t work for me.
The documentation says that this is specially done, but you can disable it
NativeDevSettings.setIsDebuggingRemotely(true);
But once you enable this option, the application starts to restart endlessly
So wait, does this mean in the future we are going to be stuck with flipper? I got nothing against it. It’s just rn-debugger fits like a glove. I’ve tried probably 5-6 times now to get used to the alternatives and they just aren’t as comfortable.
+1
same. I’ve created a new project with react-native v0.72.3 and still get this problem.