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

"Could not connect to development server" or app runs without fast refresh. #31714

Closed
victoriaSh opened this issue Jun 13, 2021 · 3 comments
Closed
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.

Comments

@victoriaSh
Copy link

victoriaSh commented Jun 13, 2021

Description

I've migrated to the new Macbook Pro M1 few weeks ago. Everything was ok but at some moment I got "could not connect to development server" error. I guess this error appeared after restarting my Wi-Fi router but I'm not sure. I managed to run app after deleting unused "expo-splash-screen" package and clearing project several times. But after several days this error appeared again and I cannot run my app anymore.

I've checked en0 in "ifconfig" and "networksetup -listallhardwareports". There is something interesting happens. When I set sourceURLForBridge in AppDelegate.m according to my ifconfig like this:
return [NSURL URLWithString:@"http://192.168.1.3:8081/index.bundle?platform=ios&dev=true&minify=false"];
I get "could not connect to development server" error. When I try to set manually bundler in dev menu with the same options( ip 192.168.1.3, port 8081) app loads but with fast refresh disabled.
Index.bundle url is reachable in my browser and other computers in my network but not on iOS devices.

If I set sourceURLForBridge this way :

NSURL *jsUrl = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
[[RCTBundleURLProvider sharedSettings] setJsLocation:jsUrl.host];
return jsUrl;

Sometimes app loads but without fast refresh. There is no "Enable/disable Fast Refresh" option in dev menu.
When I press on "Reload" app hangs.
But in most cases app just hangs on white screen after splashscreen (XCode errors below).

When I try to refresh app using terminal it says "No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB."
I created new default RN app. Fast refresh and reload don't work or app just hangs on white screen too.

I tried to run my project with my old Macbook Pro 2014 and same XCode version (12.5) and it works perfectly.

What I have already done:

  • checked that both devices are on the same Wi-Fi network
  • cleared tmp folders, watchman and build folders, restart npm with --reset-cache (million times)
  • cleaned project with react-native-clean-project
  • set recommended Flipper versions in Podfile:
    use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
  • restarted Macbook many times and iOS devices
  • deleted node modules and installed again, installed pod with "arch -x86_64 pod install"
  • run XCode with and without Rosetta
  • switch off/on Airplane mode on device to clear cache
  • uninstall/install node and watchman
  • uninstall/install XCode
  • switched on/off "Connect via network" in XCode Devices
  • placed just <View><Text>test</Text></View> in root component

I would be very grateful for any help.

React Native version:

System:
OS: macOS 11.4
CPU: (8) arm64 Apple M1
Memory: 129.41 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.3.0 - /opt/homebrew/bin/node
Yarn: Not Found
npm: 7.15.1 - /opt/homebrew/bin/npm
Watchman: 2021.06.07.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 12.5/12E262 - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.1 => 0.64.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

Have no idea.

Expected Results

App runs on real devices.

Snack, code example, screenshot, or link to a repository:

There are examples of errors I get in XCode:

2021-06-13 05:59:46.882628+0300 Videoalphabet[4112:525410] Task <2DED2650-E464-40EA-9517-0A5A5FFFEB87>.<2> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "Превышен лимит времени на запрос." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x2821599b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <2DED2650-E464-40EA-9517-0A5A5FFFEB87>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <2DED2650-E464-40EA-9517-0A5A5FFFEB87>.<2>"
), NSLocalizedDescription=Превышен лимит времени на запрос., NSErrorFailingURLStringKey=http://192.168.1.3:8081/status, NSErrorFailingURLKey=http://192.168.1.3:8081/status, _kCFStreamErrorDomainKey=4}
2021-06-13 05:59:46.917050+0300 Videoalphabet[4112:525193] [native] Invalidating <RCTCxxBridge: 0x1063058e0> (parent: <RCTBridge: 0x280424150>, executor: RCTWebSocketExecutor)
2021-06-13 05:59:46.923752+0300 Videoalphabet[4112:525936] [connection] nw_socket_handle_socket_event [C3.1:1] Socket SO_ERROR [61: Connection refused]
2021-06-13 05:59:46.924001+0300 Videoalphabet[4112:525936] [connection] nw_socket_handle_socket_event [C4.1:1] Socket SO_ERROR [61: Connection refused]
2021-06-13 05:59:46.925632+0300 Videoalphabet[4112:525936] [connection] nw_socket_handle_socket_event [C3.2:1] Socket SO_ERROR [61: Connection refused]
2021-06-13 05:59:46.925801+0300 Videoalphabet[4112:525936] [connection] nw_socket_handle_socket_event [C4.2:1] Socket SO_ERROR [61: Connection refused]
2021-06-13 05:59:46.926186+0300 Videoalphabet[4112:525746] [connection] nw_connection_get_connected_socket [C3] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-06-13 05:59:46.926453+0300 Videoalphabet[4112:525746] TCP Conn 0x281834160 Failed : error 0:61 [61]
2021-06-13 05:59:46.927792+0300 Videoalphabet[4112:525410] [connection] nw_connection_get_connected_socket [C4] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-06-13 05:59:46.927852+0300 Videoalphabet[4112:525410] TCP Conn 0x281828160 Failed : error 0:61 [61]
2021-06-13 05:59:46.992274+0300 Videoalphabet[4112:525746] [connection] nw_endpoint_handler_set_adaptive_read_handler [C5.1 64.233.165.95:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for read_timeout failed
2021-06-13 05:59:46.992311+0300 Videoalphabet[4112:525746] [connection] nw_endpoint_handler_set_adaptive_write_handler [C5.1 64.233.165.95:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for write_timeout failed
2021-06-13 05:59:47.068105+0300 Videoalphabet[4112:525757] [javascript] Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'SourceCode' could not be found. Verify that a module by this name is registered in the native binary.
2021-06-13 05:59:47.073115+0300 Videoalphabet[4112:525757] [native] Attempted to invoke `5` (method ID) on `ExceptionsManager` (NativeModule name) without a method queue.
2021-06-13 05:59:47.084269+0300 Videoalphabet[4112:525757] [native] Attempted to invoke `0` (method ID) on `Timing` (NativeModule name) without a method queue.
2021-06-13 05:59:47.084305+0300 Videoalphabet[4112:525757] [native] Attempted to invoke `1` (method ID) on `Timing` (NativeModule name) without a method queue.
2021-06-13 05:59:47.084320+0300 Videoalphabet[4112:525757] [native] Attempted to invoke `0` (method ID) on `RNCAsyncStorage` (NativeModule name) without a method queue.
2021-06-13 05:59:47.100098+0300 Videoalphabet[4112:525757] [javascript] Error: Requiring module "node_modules/react-native/Libraries/Core/InitializeCore.js", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'SourceCode' could not be found. Verify that a module by this name is registered in the native binary.
2021-06-13 05:59:47.101506+0300 Videoalphabet[4112:525757] [native] Attempted to invoke `5` (method ID) on `ExceptionsManager` (NativeModule name) without a method queue.
2021-06-13 05:59:47.105723+0300 Videoalphabet[4112:525757] [javascript] Error: Requiring module "node_modules/react-native/Libraries/Core/Devtools/getDevServer.js", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'SourceCode' could not be found. Verify that a module by this name is registered in the native binary.
2021-06-13 06:52:56.176977+0300 Videoalphabet[4438:547107] [native] 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`.
2021-06-13 06:52:56.177090+0300 Videoalphabet[4438:545280] *** Assertion failure in -[RCTCxxBridge ensureOnJavaScriptThread:](), /Volumes/Seagate/dev/react/VideoAlphabet/VideoAlphabet/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:346
2021-06-13 06:52:56.178715+0300 Videoalphabet[4438:545280] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This method must not be called before the JS thread is created'
@florinvasilevilsan
Copy link

florinvasilevilsan commented Jul 7, 2021

I am in the same boat. Not able to connect to dev server whilst running on real device: IOS/Android.

OS: macOS catalina version 10.15.7
Xcode: 12.4
React Native: 0.63.4

I am also getting this in the Xcode log output

Task <EEF81AF0-85F1-4CCA-BE68-57FFB9BBA5B9>.<2> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x283565770 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <EEF81AF0-85F1-4CCA-BE68-57FFB9BBA5B9>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <EEF81AF0-85F1-4CCA-BE68-57FFB9BBA5B9>.<2>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=http://[IP ADDRESS]:8081/status, NSErrorFailingURLKey=http://[IP ADDRESS]:8081/status, _kCFStreamErrorDomainKey=4}
Message from debugger: Terminated due to signal 9

@florinvasilevilsan
Copy link

Hi there. I found this really helpful. It saved my day https://stackoverflow.com/a/41400708/8821713

@victoriaSh
Copy link
Author

I solved this issue by running app on android device and fixing all warnings from react-native.
If I recall correctly, in my case there were:

  • AsyncStorage called before app did mount.
  • Removed conflicting packages (react-native-iap and expo in-app-purchases)

@facebook facebook locked as resolved and limited conversation to collaborators Jul 7, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants