Hello
i have issue when launch app with react native remote debugger (chrome)
blob:http://localhos…-af12390f2e7c:15184 this._constructor is not a function

the problem with realm, im sure coz then i do comment this block, app start fine with debugger-ui
package.json
{
"name": "111",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@types/jest": "^22.2.3",
"@types/react": "^16.3.14",
"@types/react-native": "^0.55.14",
"@types/react-test-renderer": "^16.0.1",
"babel-preset-react-native-stage-0": "^1.0.1",
"jest": "^23.6.0",
"jest-react-native": "^18.0.0",
"react-native-scripts-ts": "1.15.0",
"react-native-typescript-transformer": "^1.2.3",
"react-test-renderer": "16.3.1",
"ts-jest": "^22.4.6",
"tslib": "^1.9.1",
"typescript": "^2.8.3"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "jest"
},
"jest": {
"globals": {
"ts-jest": {
"useBabelrc": true
}
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"preset": "react-native",
"testMatch": [
"/__tests__//.[tj]s?(x)",
"/?(.)(spec|test).[tj]s?(x)"
],
"transform": {
"^.+\.tsx?$": "ts-jest"
}
},
"dependencies": {
"axios": "^0.19.0-beta.1",
"react": "^16.7.0-alpha.0",
"react-native": "~0.55.2",
"react-native-device-info": "^0.24.3",
"react-native-easy-grid": "^0.2.0",
"react-navigation": "^3.0.0-alpha.7",
"realm":"^2.19.0-rc.4",
"react-native-uuid":"^1.4.9"
}
}
code:
file1. export connection
import Realm from "realm";
import {rnInstallationSchema} from "./Installation/rnInstallationSchema";
export const realm = new Realm({schema: [rnInstallationSchema]});
file2.
import ... realm of course too
static async getIntallationUUID(callback?:(uuid:string)=>void) : string {
if (!realm.objects(rnInstallationSchema.schema.name).length) {
await realm.write(() => {
realm.create(rnInstallationSchema.schema.name, {
UUID: uuid.v4(),
});
})
}
let uuid=realm.objects(rnInstallationSchema.schema.name)[0].UUID;
return callback(uuid);
}
i use yarn
I've been hitting this with 2.18.0 this morning, downgrading to 2.16.2 fixes it for me
same with 2.17.0
I'm experiencing this issue with 2.18.0 (React 16.6.0, react-native 0.57.4). Downgrading to 2.17.0 resolves the issue. I'm using yarn (tried 1.9.4 and 1.12.1). I have not tried 2.19.0 yet.
same problem with 2.19.0
I've been hitting this with 2.19.0 this morning, downgrading to 2.17.0 fixes it for me
I've been hitting this with 2.19.0 this morning, downgrading to 2.17.0 fixes it for me
Make sure the version in your package.json and your-project\node_modules\realm\package.json is "2.17.0" by npm and yarn to install.
eeek!
I came face to face with this issue with realm 2.19.0. But When I try to add Version 2.17.0 (as suggested above) by yarn add [email protected] command, it fails with ...
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp build --fallback-to-build...
Version 2.19.0 _still_ installs fine (Except for the pesky this._constructor not a function error.
I am assured by many that node pre gyp is a real pain to sort out. I am at an impasse. 2.19.0 installs fine but has bugs. 2.17.0 can't even be added
Environment
Mac OS Mojave 10.14.1
react: 16.6.0-alpha.8af6728
react-native: 0.57.4
same with 2.19.0
I've commented out the line 80 from "node_modules\realm\lib\browser\index.js".
[80] //config = this._constructor(config);
[81] let schemas = typeof config == 'object' && config.schema;
[82] let constructors = schemas ? {} : null;
And now it works fine for me. I couldn't find any implementation for the function _constructor so I guess removing it won't do any side effects.
Thanks. Quick and dirty temporary solution.
Any solution here? Same in 2.19.1
In 2.20.0 the error is:
realmConstructor.Sync._initializeSyncManager is not a function
This line is causing an error while debugging in Chrome
https://github.com/realm/realm-js/blob/v2.20.0/lib/index.js#L152
if (realmConstructor.Sync) {
if (context === 'node.js') {
nodeRequire('./notifier')(realmConstructor);
if (!realmConstructor.Worker) {
Object.defineProperty(realmConstructor, 'Worker', {value: nodeRequire('./worker')});
}
}
// PROBLEM HERE
realmConstructor.Sync._initializeSyncManager(createUserAgentDescription());
}
When this line is commented out it loads fine while debugging in Chrome
@levic92 Have you been able to find a solution for this
As @levic92 explained .. the problem was on line 152 of file node_modules\realm\lib\index.js
if (realmConstructor.Sync) {
if (context === 'node.js') {
nodeRequire('./notifier')(realmConstructor);
if (!realmConstructor.Worker) {
Object.defineProperty(realmConstructor, 'Worker', {value: nodeRequire('./worker')});
}
}
///// PROBLEM HERE /////
realmConstructor.Sync._initializeSyncManager(createUserAgentDescription());
}
As the problem only happening when remote JS debugging is enabled .. so I made that line work only if not debugging ..
if (realmConstructor.Sync) {
if (context === 'node.js') {
nodeRequire('./notifier')(realmConstructor);
if (!realmConstructor.Worker) {
Object.defineProperty(realmConstructor, 'Worker', {value: nodeRequire('./worker')});
}
}
///// Check if remote JS debugging is disabled /////
if ((typeof DedicatedWorkerGlobalScope) == 'undefined') {
realmConstructor.Sync._initializeSyncManager(createUserAgentDescription());
}
}
@MujtabaFR Have you created a PR for this fix?
@HarikaSabbella I've just created a PR suggesting this fix
I believe it is fixed in https://github.com/realm/realm-js/issues/2128 and released in v2.21.0.
Hey - looks like you forgot to add a T:* label - could you please add one?
Most helpful comment
I've commented out the line 80 from "node_modules\realm\lib\browser\index.js".
And now it works fine for me. I couldn't find any implementation for the function _constructor so I guess removing it won't do any side effects.