react-native: Unable to debug new Hermes React Native app using Chrome DevTools
Description
I’m unable to debug a new React Native app that’s using Hermes by following the Hermes debugging instructions found here: https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools
Upon following those steps and opening the console in the stand alone Chrome DevTools, I see this error:
DevTools failed to load source map: Could not load content for http://localhost:8081/index.map?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.tempRN0710RC3: Fetch through target failed: Cannot read properties of null (reading 'loadNetworkResource'); Fallback: Unknown error
Nothing shows up in the Sources
tab. Navigating to that URL outside of the dev tools does load the source map file successfully.
I am able to debug successfully using Flipper - source maps seem to load fine there.
Version
0.71.0-rc.3
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 2.67 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 14.1/14B47b - /usr/bin/xcodebuild
Languages:
Java: 18.0.1.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.0-rc.3 => 0.71.0-rc.3
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
- Create a new React Native project using the command:
npx react-native init RN0710RC3 --version 0.71.0-rc.3
- Once created,
cd
in to project directory. Run usingyarn ios
oryarn android
- Follow steps outlined in Hermes debugging documentation: https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools
- Notice source maps don’t load, unable to set breakpoints.
Snack, code example, screenshot, or link to a repository
No code example since it’s reproducible using a new RN 70 or 71 project: npx react-native init RN0710RC3 --version 0.71.0-rc.3
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 20
- Comments: 38 (1 by maintainers)
The state of debugging RN has been a difficult one from the beginning. Most developers use console.log to “debug” to this day. There is no integration into VScode (which has an excellent debugger) and hermes does not improve a lot in that regard. I wonder if there are any devs out there who managed to get debugging working (consistently)?
We can’t use flipper in our case as it’s not compatible with react-native-firebase. So this issue is quite a show-stopper for our react-native upgrade initiative.
Any suggestions over how source map could be added manually? Thanks.
Just thought I’d add my two cents. This is also happening for me on 0.71.2 and Chrome Version 110.0.5481.77. Console doesn’t show logs and files don’t show up in Sources. Actually, they’ve never showed up in Sources, but I could definitely use the Console before. Also using
react-native-firebase
so cannot use Flipper. Hoping for some guidance soon, thank you!Recent versions of Chrome have stopped fetching sources from URLs in this scenario. We have an upcoming fix that will restore this functionality (by fetching the source directly, instead of via a URL). In the meantime, the easiest way to restore source loading is by using a previous version of Chrome, or Flipper.
Any updates?
I’m experiencing the same issue with react-native:0.71.12 on IOS. Subscribing…
anyone knows if this is getting adressed in v0.72 ? On Android I can debug with Hermes enabled, and it is actually a lot better in terms of performance debugging Android with Hermes, we just need to be able to debug on ios (we cant use flipper on our project)
a temporary workaround is to disable the js source maps option in the devtool 😵💫
same issue. devtools didnt work https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools
I had to temporarily disable Hermes in Podfile
:hermes_enabled => false,
for debug mode to be able to usereact-native-debugger
. Any other workarounds?I’m seeing a similar issue with react-native-debugger and RN v0.71
I’m still seeing this issue with react native v0.71.1 and Chrome 109.0.5414.119
I’m also seeing the same issue as @benrbrook with react native v0.71.1 and Chrome 109.0.5414.119
It seems like this should have been fixed in the latest 0.71 release.
https://reactnative.dev/blog/2023/01/12/version-071#hermes
However, I’m still not able to load source maps with the same error as above:
DevTools failed to load source map: Could not load content for http://localhost:8081/index.map?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=appname: Fetch through target failed: Cannot read properties of null (reading 'loadNetworkResource'); Fallback: Unknown error
Any ideas on how to get around this or if it’s still an outstanding issue? Thanks!
@jkoutavas Failed to create a new MMKV instance: React Native is not running on-device. MMKV can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.
@matthewmturner I was able to get the debugger to work when following those instructions, but only when running from XCode. We are also using Firebase.