question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specific JS fetch() fails on 0.66.4 (OR: How to debug react-native Android native code?)

See original GitHub issue

New Version

0.66.4

Old Version

0.62.2

Build Target(s)

Android debug and release

Output of react-native info

$ react-native info
info Fetching system and libraries information...
(node:36495) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 70.23 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.1 - /usr/local/bin/node
    Yarn: 1.22.1 - /usr/local/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
    Watchman: 2021.11.01.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7583922
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.10 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.66.4 => 0.66.4
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Issue and Reproduction Steps

I’m trying to call fetch in a specific point in my application, which succeeded in the previous version and the exact same call succeeds if I try it again and it happens every time. I don’t have a minimal reproducer and I’ve been debugging it for a few hours already.

I’ll note that it does work as expected on iOS.

I’m asking for some help on how to debug the actual react-native native code (not a module), I’ve found my way into sendReqeust() at ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java.

The code does log on error:

    try {
      sendRequestInternal(...);
    } catch (Throwable th) {
      FLog.e(TAG, "Failed to send url request: " + url, th);
      final RCTDeviceEventEmitter eventEmitter = getEventEmitter("sendRequest error");
      if (eventEmitter != null) {
        ResponseUtil.onRequestError(eventEmitter, requestId, th.getMessage(), th);
      }
    }

but the logs never appear, I did try using FLog.setLoggingDelegate() on my react application class with my own delegate (that uses logcat), to no avail.

Ideally I’ll be able to debug react-native code with Android Studio, but since NPM ships a binary rather than source code, it’s not possible. I could dig further to try and understand how to compile the sources but it might take a while so I’m shooting my shot here.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Avishayycommented, Jan 16, 2022

Yes, thank you.

1reaction
Avishayycommented, Jan 7, 2022

The fact that NPM ships a binary for ReactAndroid should not prevent you from debugging. If you place a breakpoint that should just work.

Android Studio doesn’t recognize that as part of the project’s code, so I can’t place breakpoints in it.

I’ll try the linked guide and keep you updated, thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native fetch() Network Request Failed - Stack Overflow
There is a very useless stack trace and I can't debug network requests in the chrome console. Here is the fetch I'm sending:...
Read more >
Troubleshooting | React Navigation
Error : While trying to resolve module "@react-navigation/native" from file ... a metro.config.js file in your project and check if you have specified...
Read more >
BlackBerry Dynamics SDK for React Native version 10.1
Known issues · On an. Android. 11 device, if the targetSdkVersion is set to 30, a. BlackBerry Dynamics. React Native. app stops responding...
Read more >
Integration with Existing Apps - React Native
The specific steps are different depending on what platform you're targeting. Android (Kotlin); Android (Java); iOS (Objective-C); iOS (Swift) ...
Read more >
possible unhandled promise rejection (id 0) axios error network ...
Here Network Request Code in studentAction.js import axios from 'axios'; import ... Possible Unhandled Promise Rejection Network Error in React Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found