upgrade-support icon indicating copy to clipboard operation
upgrade-support copied to clipboard

Cannot Connect to local debugger after update

Open mansdahlstrom1 opened this issue 5 years ago • 6 comments

Environment

System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 645.39 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 10.17.0 - /usr/local/opt/node@10/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/opt/node@10/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

Upgrading version

Went from 0.61.5 => 0.62.0 Then as i've been debugging and trying to get everything working i've now updated to 0.62.2

Description

React Native has been quite smooth for me, everything has been working since the project started until now, the first React Native upgrade for me. Since then i've lost the ability to run on a device and this is crucial to me since the app i'm building is using BLE which is not available in the simulator.

When running on device i get this messsage:

Connection to http://localhost:8081/debugger-proxy?role=client timed out. Are you running node proxy? If you are running on the device, check if you have the right IP address in RCTWebSocketExecutor.m.

To debug this issue i've tested the following

  • Validate the that the IP outputted during the build phase in xCode under Project => Report navigatior => build. According to this https://reactnative.dev/docs/running-on-device#connecting-to-the-development-server (where the issue i have is highlighted in the docs) the IP should be suffixed by xip.io, but it isn't in my case, is this just outdated documentation? Or a bug? Or something that is invalid in my configuration?

  • Tried multiple networks / changed DNS servers, (including trying it when running a personal hotspot from my iPhone)

To give some more details i've followed the this page https://react-native-community.github.io/upgrade-helper/ to update the project. After this i've also ran updates via the react native CLI.

For even more context i've noticed some strange behaviour from the after running react native start where if i press r in my terminal one time the bundler opens multiple chrome tabs with the debugger UI

[[ Here i press R one time]]
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...

Furthermore, when running in the simulator instead i get this now: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8081/debugger-ui/null' failed to load.

I've been at this for about 10 days now, very close to giving up. (really glad that i'm in a separate branch right now). Hopefully someone here can point me in the right direction as I'm quite new to native development

Reproducible demo

N/A

mansdahlstrom1 avatar Apr 16 '20 11:04 mansdahlstrom1

I've also followed this guide https://github.com/react-native-community/upgrade-helper/issues/191 btw

mansdahlstrom1 avatar Apr 16 '20 11:04 mansdahlstrom1

@mansdahlstrom1 you mentioned quite a few issues, it would help a lot if you could provide a minimal reproducible demo so people can debug your issue further.

lucasbento avatar Apr 20 '20 09:04 lucasbento

I have the same issue.

  • Upgraded from 0.60.6 to 0.62.2 (I followed the helper, #13 and #25)
  • App works when not in debugging mode
  • On iOS, when debug is on, Connection to http://localhost:8081/debugger-proxy?role=client timed out. Are you running node proxy? If you are running on the device, check if you have the right IP address in RCTWebSocketExecutor.m.
    • Also no xip.io.
  • On Android, it works as expected
System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
    Memory: 573.48 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.7.0 - /var/folders/7n/4bvcpgkj1z5dhbfx_qp6v9sr0000gn/T/yarn--1587403161032-0.44989191893512004/node
    Yarn: 1.21.1 - /var/folders/7n/4bvcpgkj1z5dhbfx_qp6v9sr0000gn/T/yarn--1587403161032-0.44989191893512004/yarn
    npm: 6.13.6 - ~/.nvm/versions/node/v13.7.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.3, 30.0.0
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

iOS Version: 13.3.1 iPhone 7

27leaves avatar Apr 20 '20 17:04 27leaves

Some context I have had the same issue after upgrading from 0.59.10 to 0.62.2. Funnily enough, doing some research on this brought me back to a comment I wrote a year ago about a similar problem with the same root cause.

Your issue comes down to the device trying to access the Metro packager at http://localhost:8081/debugger-proxy?role=client, but localhost (from the view of the device) would be the device itself, whereas the packager is still running on your MacBook. You need to make sure that the iPhone uses the (local) IP address of your MacBook instead of localhost. The post mentioned above suggests a fix for this very issue, but it seems that the internals have changed so that the fix doesn't work anymore.

The fix I was able to fix the issue by using the Configure Bundler option of the developer menu (you can open the developer menu by shaking the device) and putting in my MacBook's local IP address (port should remain 8081, if you haven't somehow changed the port the packager is running on).

Optional: If your packager isn't started at all In fact, in my case, I had an additional issue that needed to be fixed in order for things to work. The packager was not started at all when I tried to run on a device from Xcode. If you also encounter this (i.e. the packager window doesn't pop up when running from Xcode), I can recommend this fix, it worked for me.

dembe1 avatar Apr 26 '20 13:04 dembe1

I'm encountering a similar situation. Upgraded from 0.61.2 to 0.62.2, and can't run the app on simulator without errors. (Haven't tried installing on device or running a production build yet.)

Followed all the upgrade steps in the diff on https://react-native-community.github.io/upgrade-helper/?from=0.61.2&to=0.62.2

I start the Metro bundler with npx react-native start.

On starting the simulator from XCode there's a redbox with message:

Failed to execute 'importScripts' on 'workerGlobalScope': The script at 'file:///<snip>/<App_Name>.app/main.jsbundle' failed to load.

I can verify that the file exists on that path.

When I press 'Reload', I briefly see this:

Screenshot 2020-04-27 at 00 11 23

This leads me to believe the app in debug mode can't find the running metro bundler by default.

When I then trigger the debug menu with <command>+ <d>, and I choose Configure Bundler, and I fill in 127.0.0.1, port 8081 and index and I press 'Reload' in the redbox screen two times, the app finally boots up as normal.

Two questions:

  1. Why is the the generated main.jsbundle not loaded on startup?
  2. Why does the app on debug mode not find the Metro bundler by default?

CoenWarmer avatar Apr 26 '20 22:04 CoenWarmer

@dembe1 Works for me - but it is just a workaround, is it not?

At least for me I have to Configure Bundler to link to Metro every time I rerun the app. The app doesn't start up configured properly as it's supposed to.

I suspect something wrong in the Bundle React Native code and images build phase.

EDIT: My problem was fully solved here https://github.com/react-native-community/upgrade-support/issues/25#issuecomment-655245024

jamieday avatar Jul 06 '20 02:07 jamieday