realm-js: Importing Realm returns the error "Undefined is not a constructor (evaluating 'new XMLHttpRequest')"
Goals
Import Realm into a React Native project.
Expected Results
I should be able to import Realm and run the project in iOS with crashing.
Actual Results
The app crashes in release mode completely. The app crashes in debug mode if not using Chrome Debugger and I get this error on the screen:
Undefined is not a constructor (evaluating 'new XMLHttpRequest')
I get this repeating error in the console
"Must first create RPC session with a valid host".
Steps to Reproduce
I’m trying to import Realm into my React Native project and run in iOS. I’ve installed the npm and linked it. It crashes when I add the following line:
import Realm from 'realm';
Version of Realm and Tooling
- Realm JS SDK Version: 2.4.1
- Node or React Native: RN v0.46.2
- Client OS & Version: Mac OSX 10.13.4
- Which debugger for React Native: Xcode v9.3
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 31 (8 by maintainers)
seeing this issue as well w/ RN 0.59
By the way, something similar happens on Android. This message is iOS only but here is the error for both platforms :
undefined is not a constructor (evaluating 'new XMLHttpRequest()')makeRequest - rpc.js:204:22Can't find variable : Symbol<unknown> - constants.js:30:24same issue. after add ‘web3’ to my project follow this, run ios crash:
undefined is not a constructor (evaluating 'new XMLHttpRequest()')Downgrading realm works for me, and I found the problem happened after version 2.0.2:
"realm": "2.0.2"works"realm": "2.0.3"crash @sheva007 I hope it helpsSeing this too, should be reopened
what happened to me is this error occurs while I stop debug js remotely, and if i enable remote debug, works fine. What’s the problem? should i continue to use realm to do the development since app could not finally release to work ?
I still have the same error, did anyone solve it?
"realm":"2.24.0","react-native":0.55.3"Honestly I have no idea. It just started happening and since then I can’t remove that error unless I activate chrome remote debugging
@sheva007 there is a way around this, and it is frustrating. I can’t remember what I did but it was definitely a mix of uninstalling, reininstalling, relinking, resetting, etc until something clicked correctly and realm stopped fucking itself.
This really should be reopened @kneth
It works when I am remote debugging (:8081).
It does not work when not remote debugging.