0

我们有一个拥有超过 25k 用户的 react-native 应用程序,并且在过去 3 个月中在 bugsnag 中报告了超过 1000 次崩溃。崩溃通常在启动后 1 秒内发生,但有时需要几秒钟。我们无法在开发中重现这一点。它发生在ios和android上。我们唯一需要做的就是 bugsnag 提供的堆栈跟踪:

iOS bugsnag 堆栈跟踪:

TypeError Properties can only be defined on Objects. 
    [native code] defineProperty
    node_modules/react-redux/lib/connect/mergeProps.js:54:21 
    node_modules/react-native/node_modules/@babel/runtime/helpers/typeof.js:17:17 _get
    node_modules/react-redux/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js:100:11 
    node_modules/react-native/node_modules/@babel/runtime/helpers/typeof.js:17:17 _get
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 res
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 _toConsumableArray
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 _defineProperties
    [native code] value

Android bugsnag 堆栈跟踪:

TypeError Properties can only be defined on Objects. 
    [native code] defineProperty
    node_modules/react-redux/lib/utils/isPlainObject.js:20:19 
    node_modules/react-native/node_modules/@babel/runtime/helpers/typeof.js:17:17 _get
    node_modules/react-redux/lib/components/connectAdvanced.js:130:29 
    node_modules/react-native/node_modules/@babel/runtime/helpers/typeof.js:17:17 _get
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 _typeof2
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 RCTDeviceEventEmitter
    node_modules/react-native/node_modules/@babel/runtime/helpers/toConsumableArray.js:8:59 _defineProperties
    [native code] value

堆栈跟踪使我相信它与 react-redux 有关。但是我不相信这个问题在升级到 RN v 0.62 之前发生,这让我相信它可能与 RN 0.62 有关

这是 package.json 中的依赖项:

"dependencies": {
    "@emotion/core": "^10.0.16",
    "@fragaria/address-formatter": "^2.0.5",
    "@react-native-community/art": "^1.0.3",
    "@react-native-community/async-storage": "^1.8.0",
    "@react-native-community/cameraroll": "^1.3.0",
    "@react-native-community/clipboard": "^1.2.2",
    "@react-native-community/datetimepicker": "^2.1.0",
    "@react-native-community/masked-view": "^0.1.6",
    "@react-native-community/netinfo": "^5.9.0",
    "@react-native-firebase/app": "^6.4.0",
    "@react-native-firebase/crashlytics": "^6.4.0",
    "@react-native-firebase/messaging": "^6.4.0",
    "@react-navigation/bottom-tabs": "^5.1.1",
    "@react-navigation/drawer": "^5.0.6",
    "@react-navigation/native": "^5.0.9",
    "@react-navigation/stack": "^5.1.1",
    "apisauce": "^0.14.3",
    "bugsnag-react-native": "^2.20.0",
    "bugsnag-sourcemaps": "^1.0.4",
    "emotion-theming": "^10.0.14",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "moment-round": "^1.0.1",
    "prop-types": "15.6.0",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-app-auth": "^5.0.0",
    "react-native-audio-recorder-player": "^2.4.3",
    "react-native-call-detection": "^1.9.0",
    "react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",
    "react-native-config": "^0.12.0",
    "react-native-device-info": "^5.0.0",
    "react-native-fast-image": "^7.0.2",
    "react-native-geolocation-service": "^4.0.0",
    "react-native-gesture-handler": "^1.6.0",
    "react-native-google-places-autocomplete": "^1.4.1",
    "react-native-intercom": "^13.1.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-maps": "0.26.1",
    "react-native-modal": "^11.4.0",
    "react-native-notifications": "^3.1.2",
    "react-native-open-maps": "^0.3.4",
    "react-native-permissions": "~1.1.1",
    "react-native-pie": "^0.6.1",
    "react-native-progress": "^4.1.2",
    "react-native-rate": "1.1.10",
    "react-native-reanimated": "^1.7.0",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.0.0-beta.10",
    "react-native-snap-carousel": "^3.8.4",
    "react-native-sound-player": "^0.10.3",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.0.3",
    "react-native-swipe-list-view": "^2.0.3",
    "react-native-vector-icons": "6.6.0",
    "react-native-video": "^4.4.5",
    "react-native-video-controls": "^2.6.0",
    "react-native-webview": "^8.1.1",
    "react-redux": "^7.1.0",
    "redux": "^4.0.5",
    "redux-logger": "^3.0.6",
    "redux-mock-store": "^1.5.4",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "reselect": "^4.0.0",
    "rn-fetch-blob": "^0.12.0"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/plugin-proposal-class-properties": "^7.4.0",
    "@babel/preset-env": "^7.4.3",
    "@babel/runtime": "^7.9.6",
    "@storybook/addon-actions": "5.1.11",
    "@storybook/addon-knobs": "5.1.11",
    "@storybook/addon-links": "5.1.11",
    "@storybook/addon-notes": "5.1.11",
    "@storybook/addon-ondevice-actions": "5.1.11",
    "@storybook/addon-ondevice-knobs": "5.1.11",
    "@storybook/addon-ondevice-notes": "5.1.11",
    "@storybook/addon-storyshots": "5.1.11",
    "@storybook/addons": "5.1.11",
    "@storybook/react-native": "5.1.11",
    "babel-eslint": "^10.0.2",
    "babel-jest": "^24.9.0",
    "babel-loader": "^7.1.5",
    "babel-plugin-module-resolver": "^3.2.0",
    "babel-polyfill": "7.0.0-beta.3",
    "eslint": "^5.16.0",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-import-resolver-babel-module": "^5.1.0",
    "eslint-plugin-import": "2.2.0",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "7.12.4",
    "jest": "24.9.0",
    "jest-plugin-context": "^2.9.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-addons-test-utils": "~15.4.1",
    "react-dom": "16.8.3",
    "react-native-testing-library": "^2.1.0",
    "react-test-renderer": "^16.13.1",
    "wd": "^1.11.4"
  }

关于问题可能是什么的任何线索?

4

1 回答 1

1

我遇到了同样的错误“TypeError Properties can only be defined on Objects [native code] defineProperty”。我通过使用@react-native-firebase/messaging 替换一些代码来解决它。

您可以尝试替换代码

`
useEffect(() => {
    messaging().getToken().then(token => {
      //some logic code
    });
    return messaging().onTokenRefresh(token => {
      //some logic code
    });
}, []);
`

`
useEffect(() => {
    messaging().getToken().then(token => {
      //some logic code
    }); 
    messaging().onTokenRefresh(token => {
      //some logic code
    });
}, []);
`
于 2020-08-01T05:21:25.473 回答