realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Expo application crashing with "property is not configurable" error

Open thecoorum opened this issue 3 years ago • 10 comments

Description

After installing the Hermes version of Realm the app starts crashing with a property is not configurable error on the following lines in extensions.js

    Object.defineProperties(realmConstructor.App.Sync.MutableSubscriptionSet.prototype, {
      ...getOwnPropertyDescriptors(mutableSubscriptionSetMethods.instance),
    });

Stacktrace & log output

No response

Can you reproduce a bug?

Yes, always

Reproduction Steps

  1. Install Hermes version of Realm
  2. Launch the app

Version

10.20.0.beta-5

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

iOS 15.0

thecoorum avatar Jun 07 '22 07:06 thecoorum

@thecoorum Thanks of reporting. I am able to reproduce this in both Expo and a vanilla React Native project. We will investigate and get back to you when we have a solution.

takameyer avatar Jun 08 '22 07:06 takameyer

@takameyer thanks for quick reply, waiting for the update

thecoorum avatar Jun 08 '22 07:06 thecoorum

I have the same issue, but only when i import a item from "@realm/react". without this import, the Expo application not crashing.

Platform : Android 10

ppsoftci avatar Jun 08 '22 15:06 ppsoftci

@ppsoftci do you have a node_modules/@realm/react/node_modules/realm directory - if yes, what's the version in its package.json?

I managed to reproduce the crash locally, when I was running the v11 version of our JS code (from ./lib) but while the binaries were from an older version (where the binary sets the add and remove methods on the MutableSubscriptionSet ). You can try deleting node_modules/realm and alternatively await the upcoming v11.0.0-rc.0 which should have this issue resolved.

kraenhansen avatar Jun 09 '22 07:06 kraenhansen

@kraenhansen below, is the content of the package.json file

"@native-base/icons": "^0.0.11",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-masked-view/masked-view": "0.2.6",
"@react-navigation/bottom-tabs": "^6.2.0",
"@react-navigation/material-bottom-tabs": "^6.1.1",
"@react-navigation/material-top-tabs": "^6.1.1",
"@react-navigation/native": "^6.0.8",
"@react-navigation/native-stack": "^6.5.0",
"@react-navigation/stack": "^6.1.1",
"@realm/react": "^0.3.1"
"@reduxjs/toolkit": "^1.8.2",
"axios": "^0.26.1",
"expo": "^45.0.0",
"expo-app-loading": "~2.0.0",
"expo-asset": "~8.5.0",
"expo-camera": "~12.2.0",
"expo-constants": "~13.1.1",
"expo-crypto": "~10.2.0",
"expo-dev-client": "~0.9.6",
"expo-file-system": "~14.0.0",
"expo-firebase-recaptcha": "~2.2.0",
"expo-font": "~10.1.0",
"expo-linear-gradient": "~11.3.0",
"expo-local-authentication": "~12.2.0",
"expo-notifications": "~0.15.2",
"expo-random": "~12.2.0",
"expo-secure-store": "~11.2.0",
"expo-sharing": "~10.2.0",
"expo-splash-screen": "~0.15.1",
"expo-sqlite": "~10.2.0",
"expo-status-bar": "~1.3.0",
"firebase": "^9.8.2",
"lodash": "^4.17.21",
"native-base": "^3.4.3",
"prop-types": "^15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-app-intro-slider": "^4.0.4",
"react-native-awesome-alerts": "^1.5.2",
"react-native-calculator": "^0.5.2",
"react-native-confirmation-code-field": "^7.3.0",
"react-native-dotenv": "^3.3.1",
"react-native-flash-message": "^0.2.1",
"react-native-get-random-values": "~1.8.0",
"react-native-loading-spinner-overlay": "^2.0.0",
"react-native-logs": "^4.0.1",
"react-native-pager-view": "5.4.15",
"react-native-paper": "^4.11.2",
"react-native-purchases": "^4.5.3",
"react-native-safe-area-context": "4.2.4",
"react-native-screens": "~3.11.1",
"react-native-svg": "12.3.0",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^9.1.0",
"react-native-web": "0.17.7",
"react-native-webview": "11.18.1",
"react-redux": "^8.0.1",
"realm": "^10.20.0-beta.5"

ppsoftci avatar Jun 09 '22 10:06 ppsoftci

What about the node_modules/@realm/react/node_modules/realm/package.json? (if you have that file on the system) I'm contemplating that perhaps @realm/react is side-loading its own version of the ./lib code.

kraenhansen avatar Jun 09 '22 11:06 kraenhansen

node_modules/@realm/react/node_modules/realm/package.json

{ "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", "version": "10.19.1", "license": "See the actual license in the file LICENSE", "homepage": "https://realm.io", "keywords": [ "database", "db", "react", "react-native", "persistence", "localstorage", "sqlite", "asyncstorage", "rocksdb", "leveldb", "realm" ], "author": { "name": "Realm", "email": "[email protected]", "url": "https://realm.io" }, "repository": { "type": "git", "url": "https://github.com/realm/realm-js.git" }, "bugs": { "url": "https://github.com/realm/realm-js/issues" }, "types": "types/index.d.ts", "main": "lib/index.js", "files": [ "cmake", "lib", "types", "react-native", "scripts", "src", "vendor", "dependencies.list", "react-native.config.js", "RealmJS.podspec", "CMakeLists.txt" ], "scripts": { "lerna:bootstrap": "lerna bootstrap", "lerna:lint": "lerna run lint", "lerna:lint:fix": "lerna run lint --no-bail -- -- --fix", "lint": "eslint .", "get-version": "node -p process.env.npm_package_version", "set-version": "scripts/set-version.sh", "test": "scripts/test.sh", "package": "npm ci --ignore-scripts && prebuild", "install": "prebuild-install -r napi || cmake-js build", "rebuild": "npm run rebuild-changes", "build": "npm run build-changes", "build:arm": "npm run build-changes:arm", "build-changes": "cmake-js build --debug", "build-changes:x64": "cmake-js build --debug --arch x64", "build-changes:arm": "cmake-js build --debug --arch arm64", "rebuild-changes": "cmake-js rebuild --debug && cd tests && npm install", "license-check": "npm install && license-checker --exclude "MIT,ISC,BSD,Apache-2.0,BSD-2-Clause,BSD-3-Clause,WTFPL,Unlicense,(MIT AND CC-BY-3.0)" | node scripts/handle-license-check.js", "jsdoc:clean": "rimraf ./docs/output", "jsdoc": "npm install --ignore-scripts && npm run jsdoc:clean && jsdoc -u docs/tutorials -p package.json -c docs/conf.json", "doxygen:clean": "rm -rf contrib/docs/output/realm/", "doxygen": "REALM_JS_VERSION=$npm_package_version npm run doxygen:clean && doxygen contrib/docs/doxygen.cfg", "prenode-tests": "npm install --build-from-source && cd tests && npm install", "node-tests": "cd tests && npm run test && cd ..", "start-server": "RUN_STITCH_IN_FORGROUND=true ./scripts/start-sync-server.sh", "test-runner:ava": "cd tests/test-runners/ava && npm install --build-from-source=realm && npm test", "test-runner:mocha": "cd tests/test-runners/mocha && npm install --build-from-source=realm && npm test", "test-runner:jest": "cd tests/test-runners/jest && npm install --build-from-source=realm && npm test", "test-runners": "npm run test-runner:ava && npm run test-runner:mocha && npm run test-runner:jest", "check-environment": "node scripts/check-environment.js", "lint:cpp": "find src -name ".?pp" | xargs clang-format --dry-run --Werror", "lint:fix:cpp": "find src -name "*.?pp" | xargs clang-format -i", "postinstall": "node scripts/submit-analytics.js" }, "dependencies": { "@realm.io/common": "^0.1.1", "bindings": "^1.5.0", "bson": "4.4.1", "clang-format": "^1.6.0", "command-line-args": "^5.1.1", "deepmerge": "2.1.0", "fs-extra": "^4.0.3", "ini": "^1.3.7", "node-addon-api": "4.2.0", "node-fetch": "^2.6.1", "node-machine-id": "^1.1.10", "prebuild-install": "^7.0.1", "progress": "^2.0.3", "prop-types": "^15.6.2", "realm-network-transport": "^0.7.2", "request": "^2.88.0", "stream-counter": "^1.0.0", "sync-request": "^3.0.1", "tar": "^6.0.1", "url-parse": "^1.4.4" }, "peerDependencies": { "react-native": ">=0.60" }, "peerDependenciesMeta": { "react-native": { "optional": true } }, "devDependencies": { "@babel/runtime": "^7.16.3", "@react-native-community/eslint-config": "^3.0.0", "@types/node": "^4.9.1", "@typescript-eslint/eslint-plugin": "^4.28.3", "@typescript-eslint/parser": "^4.28.3", "babel-eslint": "^8.2.6", "cmake-js": "^6.1.0", "compare-versions": "^3.6.0", "eslint": "^7.30.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-flowtype": "^5.8.0", "eslint-plugin-header": "^3.1.1", "eslint-plugin-jasmine": "^4.1.2", "eslint-plugin-jsdoc": "^35.4.1", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-native": "^3.11.0", "fb-watchman": "^2.0.1", "jasmine": "^3.4.0", "jasmine-console-reporter": "^3.1.0", "jasmine-xml-reporter": "^1.2.1", "jsdoc": "3.6.3", "lerna": "^4.0.0", "license-checker": "^8.0.3", "mockery": "^2.0.0", "prebuild": "^10.0.1", "prettier": "^2.0.4", "rimraf": "^2.6.3", "semver": "^5.6.0", "shelljs": "^0.8.5", "shx": "^0.2.2", "ts-node": "^10.4.0", "typescript": "^4.5.2" }, "engines": { "node": ">=13", "npm": ">=7" }, "config": { "runtime": "napi", "target": 5 }, "binary": { "module_name": "realm", "host": "https://static.realm.io", "package_name": "realm-v{version}-napi-v5-{platform}-{arch}.tar.gz", "remote_path": "realm-js-prebuilds/{version}", "napi_versions": [ 5 ] } }

ppsoftci avatar Jun 09 '22 12:06 ppsoftci

Yep - this seems to be triggered by @realm/react having a dependency on realm and the 10.20.0-beta.5 being a pre-release.

Try removing the nested realm directory and rebuild the app:

rm -rf node_modules/@realm/react/node_modules/realm

kraenhansen avatar Jun 09 '22 12:06 kraenhansen

After deleting the directory, the application works fine without crashing but without the use of "UserProvider".

When I use "UserProvider" the app crash with if this error: "TypeError: app.addListener is not a function. (In 'app.addListener(event)', 'app.addListener' is undefined)"

  return (
    <AppProvider id={APP_ID}>
      <UserProvider fallback={(<Text>not logged</Text>)}>
          <View style={styles.container}>
              <Text>Open up App.js to start working on your app!</Text>
              <StatusBar style="auto" />
            </View>
      </UserProvider>
    </AppProvider>
  );

ppsoftci avatar Jun 09 '22 13:06 ppsoftci

Thanks for verifying the workaround. Unfortunately the 10.20.0-beta.5 is lacking some features that the lastest actual release has and Realm React is depending on. You'd have to await the next Hermes release, which we're currently hard at work on getting published.

kraenhansen avatar Jun 09 '22 13:06 kraenhansen

We have released v11.0.0, and we would like to know if upgrading solve your issue.

kneth avatar Oct 20 '22 12:10 kneth

Yeah, this solved my issue, thanks a lot!

thecoorum avatar Nov 02 '22 15:11 thecoorum