Closed nomoreboredom closed 4 years ago
@nomoreboredom thanks for reporting this! Could you poke around in https://github.com/tradle/react-native-http/blob/master/lib/response.js and see why response.headers
isn't being defined in your case? (If that's where the response
object is coming from. If not, where is it being created?)
My app is throwing on this line actually, from xhr2-cookies, xml-http-request.js file line:
if (this.withCredentials && (response.headers['set-cookie'] || response.headers['set-cookie2'])) {
XMLHttpRequest.cookieJar.setCookies(response.headers['set-cookie'] || response.headers['set-cookie2']);
}
and if I add this check, it stops to throw but I can not build the connection I am supposed to build.
if (this.withCredentials && ((response.headers && response.headers['set-cookie']) || (response.headers && response.headers['set-cookie2']))) {
XMLHttpRequest.cookieJar.setCookies(response.headers['set-cookie'] || response.headers['set-cookie2']);
}
Hmm actually it may be a web3 bug, as I just noticed this issue: https://github.com/ethereum/web3.js/issues/1802.
Thanks anyway, will follow that issue and reopen this if it still persists :)
So I traced down the issue to this change from web3 lib:
var XHR2 = require('xhr2-cookies').XMLHttpRequest; // jshint ignore: line
It was before just using XMLHttpRequest, whereas it now uses a lib for managing cookies. But as the cookie storage is not per default available for react native, do you think I need to nodeify this using this a package like this, or is it perhaps already done via react-native-http? https://github.com/joeferraro/react-native-cookies
Thanks!
@nomoreboredom no idea yet :) Can you check why the response is being created without a headers
field? That doesn't sound right. And is the response
object being created from inside react-native-http
or elsewhere?
Same issue
web3 issue . downgrade to v1.0.0-beta.33 solved my problem.
Running into the same issue, also trying to make web3
work. In my case, Cannot read property 'node' of undefined
is throwing out of XMLHttpRequest
. Going to see if downgrading fixes things.
EDIT: Maybe, although not quite. I do get a different error, but now it says that it can't connect. Currently trying to get an HTTPProvider to talk to local Ganache from the Android emulator, no dice. Could be related to something else, though.
closing as web3 issue. If anyone wants to poke around with improving compatibility, happy to reopen
hi @mvayngrib
Currently i am experiencing a problem. Normally nodeifying was working pretty good, but however after the latest web3-core update, (web3.js 1.0.0-beta.35, see breaking change: The HTTP provider now accepts an options object, instead of timeout and headers parameters:) this line fails on xhr2-cookies:
and throws
Cannot read property 'set-cookie' of undefined.
If I do comment out response.headers['set-cookie'] parts from the node module xhr2-cookies, i do get a ssl error when i try to connect to ethereum rpc node. So this cookie is normally using browser cache I think, whereas we dont have a substitude for that from rn-nodeify. Is this assumption correct, what do you think?
Cheers