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.

Running example code results in network error at RN fetch()

See original GitHub issue

First of all: Thanks for this project!

I am checking out the /example code and when running as described in the README and without modifications I get following error:

TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (fetch.js:441)
    at XMLHttpRequest.dispatchEvent (event-target.js:172)
    at XMLHttpRequest.setReadyState (XMLHttpRequest.js:546)
    at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:381)
    at XMLHttpRequest.js:485
    at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
    at MessageQueue.__callFunction (MessageQueue.js:260)
    at MessageQueue.js:101
    at MessageQueue.__guard (MessageQueue.js:228)
    at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:100)

I will look into this further, but maybe there is something obvious I am overlooking…

(Versions: yarn 0.24.6, npm 4.2.0, ubuntu 16.04, (local) node: 7.10.1)

PS I will try again with downgraded node on ubuntu system

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:21 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
aschrijvercommented, Aug 17, 2017

Hi @staltz

I got it working by refactoring to J2V8:

Steps:

  • clone J2V8
  • python build.py --interfactive (using the not-yet-merged build improvement PR)
  • import j2v8-release.aar in react-native-node (8.7 MB, Node 7.9.0 for me, soon 8.1.2)
  • in react-native-node compile project(':j2v8-release')
  • node application is at android/app/src/main/assets (will refactor this to be ./Background)
  • remove any non-standard RN stuff from the gradle projects

Then RNNodeService.java like this:

(PS You don’t need a V8Thread. A normal one will do)

For some reason I had to redefine RNNodeModule.start to have no parameters when called with no parameters from RN, otherwise I ended up with error NativeArgumentsParseException got 0 arguments expected 1. Will look into this later.

I now know much more on J2V8 now (see Viable options to running NodeJS on Android (Aug 2017)) and am convinced that both react-native-node and node-on-android would benefit by using this as a basis to build on further. It would not add any overhead in the way the project is working now, and gives some powerful options in e.g. communicating between RN and Node.

I will keep you posted on more findings.

2reactions
aschrijvercommented, Aug 23, 2017

This is current status: https://github.com/eclipsesource/J2V8/issues/332 May be solved when J2V8 is ready to build Node 8.4.0 (which is almost)

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native fetch() Network Request Failed - Stack Overflow
I was using localhost for the address, which was obviously wrong. After replacing it with the IP address of the server (in the...
Read more >
Error Handling for Network Requests in Client-Side JavaScript ...
We have an err object, representing the Error that Axios creates for us, but the error message is generic: “Request failed with status...
Read more >
Networking - React Native
React Native provides the Fetch API for your networking needs. ... The above examples show how you can make a request.
Read more >
request failed with status code 400 react native - You.com
React Native API fetch error Request failed with status code 400 ... api/zomato'; export default () => { const [results, setResults] = useState([]); ......
Read more >
react-native-blob-util - npm
Start using react-native-blob-util in your project by running `npm i ... React-Native-Blob-Util is fully compatible with RN-Fetch-Blob and ...
Read more >

github_iconTop Related Medium Post

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