Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to debug new Hermes React Native app using Chrome DevTools #35600

Closed
DigitalZebra opened this issue Dec 9, 2022 · 45 comments
Closed

Unable to debug new Hermes React Native app using Chrome DevTools #35600

DigitalZebra opened this issue Dec 9, 2022 · 45 comments
Assignees
Labels
Debugger Issues related to React Native DevTools or legacy JavaScript/Hermes debugging Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon. Tech: Hermes Hermes Engine: https://hermesengine.dev/

Comments

@DigitalZebra
Copy link

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

  1. Create a new React Native project using the command: npx react-native init RN0710RC3 --version 0.71.0-rc.3
  2. Once created, cd in to project directory. Run using yarn ios or yarn android
  3. Follow steps outlined in Hermes debugging documentation: https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools
  4. 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

image

@cortinico cortinico added the Tech: Hermes Hermes Engine: https://hermesengine.dev/ label Dec 9, 2022
@mattbfb
Copy link
Contributor

mattbfb commented Dec 9, 2022

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.

@Kasik-D
Copy link

Kasik-D commented Dec 16, 2022

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

image

@DigitalZebra
Copy link
Author

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.

@hishammalik
Copy link

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.

@benrbrook
Copy link

benrbrook commented Jan 20, 2023

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

@wadeww
Copy link

wadeww commented Jan 25, 2023

I'm still seeing this issue with react native v0.71.1 and Chrome 109.0.5414.119

@robincwillis
Copy link

I'm also seeing the same issue as @benrbrook with react native v0.71.1 and Chrome 109.0.5414.119

@bcsaxon
Copy link

bcsaxon commented Feb 6, 2023

I'm seeing a similar issue with react-native-debugger and RN v0.71

@itsmeshusha
Copy link

same issue. devtools didnt work https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools

@gabriellend
Copy link

gabriellend commented Feb 15, 2023

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!

@jaexplorer
Copy link

I also cannot get this to work with react-native-debugger and RN v0.71. Any update?

@matthewmturner
Copy link

It seems source maps are disabled by default. Could that be related?

@dnelsonlivecurrence
Copy link

@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.

@pratt3351
Copy link

any updates ?

@nguyenthetoan
Copy link

image
a temporary workaround is to disable the js source maps option in the devtool 😵‍💫

@yusufseyrek
Copy link

This seems to be still happening on 0.71.4. Has anyone able to find a workaround?

@hpelitebook745G2
Copy link

hpelitebook745G2 commented Apr 2, 2023

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?

@jaexplorer
Copy link

Do you need to also disable hermes in Android for it to work?
If so, how do you disable hermes in Android?

@hpelitebook745G2
Copy link

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
    }

@lunaleaps lunaleaps self-assigned this Apr 13, 2023
@pke
Copy link

pke commented Apr 27, 2023

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)?

@willTerner
Copy link

Still have this problem. It seems that I should use use older version of react native.

@Lakston
Copy link

Lakston commented Jun 7, 2023

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)

@surbhidavara99
Copy link

Having the same issue in react-native:0.71.8, getting this error: Calling synchronous methods on native modules is not supported in Chrome.

@R4DIC4L
Copy link

R4DIC4L commented Jun 29, 2023

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?

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. :(

@lunaleaps lunaleaps added the Debugger Issues related to React Native DevTools or legacy JavaScript/Hermes debugging label Jul 5, 2023
@mandrade2
Copy link

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'

@Barrakkuda
Copy link

I'm experiencing the same issue with react-native:0.71.12 on IOS. Subscribing...

@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@github-actions github-actions bot added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Jul 22, 2023
@saurabhsaneja
Copy link

saurabhsaneja commented Sep 11, 2023

temporary solution

in android/app/build.gradle file

in dependencies
reverse if else case for hermesEnabled.toBoolean()

@jkoutavas
Copy link

This works for me: https://github.com/gusgard/react-native-devsettings

@saurabhsaneja
Copy link

saurabhsaneja commented Oct 27, 2023

[@jkoutavas]) thanks.. I will try

app://arkansasSaneja

@HoangTrongKhanh
Copy link

This works for me: https://github.com/gusgard/react-native-devsettings

Sorry, Im using MKKV so this library didnt work for me

@HoangTrongKhanh
Copy link

Any updates?

@jkoutavas
Copy link

This works for me: https://github.com/gusgard/react-native-devsettings

Sorry, Im using MKKV so this library didnt work for me

Do you mean this? https://github.com/mrousavy/react-native-mmkv

If so, why doesn't it work?

@antoniovuono
Copy link

Same issue here in React Native: 0.71.11

@CrazyStoneJy
Copy link

same issue in 0.72.6

@ou2s
Copy link

ou2s commented Nov 22, 2023

Same issue with 0.72.7... Unable to have breakpoint working on Flipper with a new project on iOS.

@JsonKit
Copy link

JsonKit commented Dec 15, 2023

@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.

@Hao-yiwen
Copy link

I have a little same question.I found my breakpoints will not work when I press "R" to refresh my page.

@react-native-bot
Copy link
Collaborator

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

1 similar comment
@react-native-bot
Copy link
Collaborator

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 20, 2024
@react-native-bot
Copy link
Collaborator

This issue was closed because it has been stalled for 7 days with no activity.

@react-native-bot react-native-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2024
@markalanevans
Copy link

Same issue.

@linkecoding
Copy link

I think I found a temporary solution by using a lower version of the Chrome browser for debugging. After my test, the browser version 80.0.3987.149 can be debugged. You can download it at this link,google-chrome-old-version

@linkecoding
Copy link

I am currently using React Native 0.73.4, Android device, I tried several ways, and finally found the following differences

  1. If I set the value of [Debug server host & port for device] to my computer's [ip ​​address: 8081] through the debug panel's [Settings], an error [Failed to fetch source url http://192.168.31.228:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.reactnativesample&modulesOnly=false&runModule=true: remote fetches not permitted] will appear
  2. If I set it to [localhost:8081] in the same way, and use USB to connect the device, and execute the command [adb reverse tcp:8081 tcp:8081], my latest version of Chrome can load source map files and debug normally code, the above error will not occur
  3. If I set it to [127.0.0.1:8081], a loading error will also occur
    So the current appropriate solution is to set the value of [Debug server host & port for device] to localhost:8081 and execute [adb reverse tcp:8081 tcp:8081]

@linkecoding
Copy link

For users who use the iOS simulator, the feasible method is:

  1. Get the IP address of your PC, assuming it is 192.168.31.3
  2. Edit the file [/etc/hosts], which requires sudo permissions, and add a line to this file:

localhost 192.168.31.3

In this way, your simulator can still use localhost to pull RN's js files, but it will be pointed to the local server of your computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debugger Issues related to React Native DevTools or legacy JavaScript/Hermes debugging Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon. Tech: Hermes Hermes Engine: https://hermesengine.dev/
Projects
None yet
Development

No branches or pull requests