react-native
react-native copied to clipboard
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,
cdin to project directory. Run usingyarn iosoryarn 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
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.
Hi, same issues
System: OS: macOS 12.6 CPU: (8) arm64 Apple M1 Memory: 116.91 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.17.0 - /usr/local/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.15.0 - /usr/local/bin/npm Watchman: 2022.09.26.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/danil/.rvm/gems/ruby-2.7.5/bin/pod 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: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.0/14A309 - /usr/bin/xcodebuild Languages: Java: 11.0.16.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Thanks @mattbfb - would you recommend I close this or leave it open for tracking purposes? Thanks again for the background - I'll use Flipper for the time being.
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.
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.
It seems like this should have been fixed in the latest 0.71 release.
By loading source maps over the network with Metro we’ve restored the ability to use source maps in recent versions of Chrome Dev Tools outside of Flipper.
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!
System:
OS: macOS 13.1
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 27.85 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.1.0 - /usr/local/bin/node
Yarn: 1.22.19 - ~/project-name/node_modules/.bin/yarn
npm: 8.19.3 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /Users/bbrook/.rbenv/shims/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: Not Found
Xcode: 14.1/14B47b - /usr/bin/xcodebuild
Languages:
Java: 16.0.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.1 => 0.71.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
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
I'm seeing a similar issue with react-native-debugger and RN v0.71
same issue. devtools didnt work https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools
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!
I also cannot get this to work with react-native-debugger and RN v0.71. Any update?
It seems source maps are disabled by default. Could that be related?
@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.
any updates ?
a temporary workaround is to disable the js source maps option in the devtool 😵💫
This seems to be still happening on 0.71.4. Has anyone able to find a workaround?
I had to temporarily disable Hermes in Podfile :hermes_enabled => false, for debug mode to be able to use react-native-debugger. Any other workarounds?
Do you need to also disable hermes in Android for it to work? If so, how do you disable hermes in Android?
Android seems fine and I can use still react-native-debugger without disabling Hermes so I only do it in iOS. But to answer your question, I'm using the latest RN 0.71.4 so it should be in android/app/build.gradle and invert the flag hermesEnabled:
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
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)?
Still have this problem. It seems that I should use use older version of react native.
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)
Having the same issue in react-native:0.71.8, getting this error: Calling synchronous methods on native modules is not supported in Chrome.
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 am using RN 0.70.10 and cannot have both hermes disabled and flipper disabled as I get a build errors related to hermes.h or Thread 1: signal SIGABRT because of "Library not loaded: @rpath/hermes.framework/hermes".
Edit: Solved this crash by doing as suggested here, but debugging still doesn't work. Still getting error even with hermes on false and flipper disabled: info Opening flipper://null/Hermesdebuggerrn?device=React%20Native... error Browser exited with error:, Error: invalid url, missing http/https protocol
Did you do any other command apart from the disabling of hermes and pod install again? I also see that my project's /* [CP] Embed Pods Frameworks */ task is being deleted from the project.pbxproj after disabling hermes, is this normal?
I am also using react-native-firebase, so I cannot use Flipper. This is making it impossible to debug the iOS app on Mac. :(
Still seeing this as of react-native:0.71.12 on IOS.
Tried generating a bundle with a sourcemap by adding the sourcemap-output flag to my build command (see below) and adding export SOURCEMAP_FILE="$(pwd)/../main.jsbundle.map"; to my ios/.xcode.env file as stated here. With this I do see a sourcemap file created but somehow it is not being picked up by the chrome debugger.
The whole build command I used is this react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=true --platform='ios' --sourcemap-output='./ios/main.jsbundle.map'
I'm experiencing the same issue with react-native:0.71.12 on IOS. Subscribing...
| :warning: | Missing Reproducible Example |
|---|---|
| :information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
temporary solution
in android/app/build.gradle file
in dependencies reverse if else case for hermesEnabled.toBoolean()
This works for me: https://github.com/gusgard/react-native-devsettings
[@jkoutavas]) thanks.. I will try
app://arkansasSaneja