realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

TypeError: Cannot read property 'size' of undefined #6626

Open ronkorland opened 4 weeks ago

ronkorland commented 4 weeks ago

How frequently does the bug occur?

Always

Description

realm: 12.6.2 @realm/react: 0.6.2

I created one react-native page inside react-router; the page uses the useQuery hook to query my model. When I open the page, I always get the following error: TypeError: Cannot read property 'size' of undefined

Stacktrace & log output

get (Results.js:62)
getOwnPropertyDescriptor (OrderedCollection.js:62)
set (OrderedCollection.js:51)
Results (Results.js:33)
objects (Realm.js:691)
getObjects (index.cjs:151)
anonymous (index.cjs:182)
mountMemo (ReactNativeRenderer-dev.js:11819)
useMemo (ReactNativeRenderer-dev.js:12275)
useMemo (react.development.js:1650)
useQuery (index.cjs:181)
RealmDbPage (MainPage.tsx:30)
renderWithHooks (ReactNativeRenderer-dev.js:10867)
mountIndeterminateComponent (ReactNativeRenderer-dev.js:14789)
beginWork (ReactNativeRenderer-dev.js:16628)
beginWork$1 (ReactNativeRenderer-dev.js:22324)
performUnitOfWork (ReactNativeRenderer-dev.js:21471)
workLoopSync (ReactNativeRenderer-dev.js:21398)
renderRootSync (ReactNativeRenderer-dev.js:21369)
performSyncWorkOnRoot (ReactNativeRenderer-dev.js:21020)
flushSyncCallbacks (ReactNativeRenderer-dev.js:6262)
flushSyncCallbacksOnlyInLegacyMode (ReactNativeRenderer-dev.js:6241)
batchedUpdates$1 (ReactNativeRenderer-dev.js:21076)
batchedUpdates (ReactNativeRenderer-dev.js:2750)
_receiveRootNodeIDEvent (ReactNativeRenderer-dev.js:2892)
receiveTouches (ReactNativeRenderer-dev.js:3012)
__callFunction (MessageQueue.js:433)
anonymous (MessageQueue.js:113)
__guard (MessageQueue.js:365)
callFunctionReturnFlushedQueue (MessageQueue.js:112)

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

12.6.2

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android 13

Build environment

Which debugger for React Native: Flipper

Cocoapods version

No response

sync-by-unito[bot] commented 4 weeks ago

➤ PM Bot commented:

Jira ticket: RJS-2805

kneth commented 3 weeks ago

@ronkorland Please provide a reproduction case or at least a stack trace.

ronkorland commented 3 weeks ago

@kneth the following stack trace is not enough?

get (Results.js:62)
getOwnPropertyDescriptor (OrderedCollection.js:62)
set (OrderedCollection.js:51)
Results (Results.js:33)
objects (Realm.js:691)
getObjects (index.cjs:151)
anonymous (index.cjs:182)
mountMemo (ReactNativeRenderer-dev.js:11819)
useMemo (ReactNativeRenderer-dev.js:12275)
useMemo (react.development.js:1650)
useQuery (index.cjs:181)
RealmDbPage (MainPage.tsx:30)
renderWithHooks (ReactNativeRenderer-dev.js:10867)
mountIndeterminateComponent (ReactNativeRenderer-dev.js:14789)
beginWork (ReactNativeRenderer-dev.js:16628)
beginWork$1 (ReactNativeRenderer-dev.js:22324)
performUnitOfWork (ReactNativeRenderer-dev.js:21471)
workLoopSync (ReactNativeRenderer-dev.js:21398)
renderRootSync (ReactNativeRenderer-dev.js:21369)
performSyncWorkOnRoot (ReactNativeRenderer-dev.js:21020)
flushSyncCallbacks (ReactNativeRenderer-dev.js:6262)
flushSyncCallbacksOnlyInLegacyMode (ReactNativeRenderer-dev.js:6241)
batchedUpdates$1 (ReactNativeRenderer-dev.js:21076)
batchedUpdates (ReactNativeRenderer-dev.js:2750)
_receiveRootNodeIDEvent (ReactNativeRenderer-dev.js:2892)
receiveTouches (ReactNativeRenderer-dev.js:3012)
__callFunction (MessageQueue.js:433)
anonymous (MessageQueue.js:113)
__guard (MessageQueue.js:365)
callFunctionReturnFlushedQueue (MessageQueue.js:112)
Mitch528 commented 3 weeks ago

I have the same issue. Seems to have happened after upgrading to react-native 0.74.

ronkorland commented 3 weeks ago

I'm using react-native: 0.73.6 but I have the same issue

Mitch528 commented 2 weeks ago

I'm using react-native: 0.73.6 but I have the same issue

@ronkorland

do you have this@babel/plugin-transform-private-methods in your babel config? That seems to have been the cause, at least it was for me.

I fixed it by removing it and adding this to my config instead:

  overrides: [
    {
      exclude: /node_modules\/realm\//,
      plugins: [['@babel/plugin-transform-private-methods', { loose: true }]],
    },
  ],
ronkorland commented 2 weeks ago

I'm using react-native: 0.73.6 but I have the same issue

@ronkorland

do you have this@babel/plugin-transform-private-methods in your babel config? That seems to have been the cause, at least it was for me.

I fixed it by removing it and adding this to my config instead:

  overrides: [
    {
      exclude: /node_modules\/realm\//,
      plugins: [['@babel/plugin-transform-private-methods', { loose: true }]],
    },
  ],

Thanks for reply, me babel config looks like this:

module.exports = {
  presets: [["module:@react-native/babel-preset"]],
  env: {
    production: {
      plugins: ["react-native-paper/babel"],
    },
  },
  plugins: [
    "@realm/babel-plugin",
    "babel-plugin-transform-typescript-metadata",
    ["@babel/plugin-proposal-decorators", { legacy: true }],
    ["@babel/plugin-transform-class-properties", { loose: true }],
    ["@babel/plugin-transform-private-property-in-object", { loose: true }],
  ],
  overrides: [
    {
      exclude: /node_modules\/realm\//,
      plugins: [["@babel/plugin-transform-private-methods", { loose: true }]],
    },
  ],
};

But I still have the same error. untitled

Mitch528 commented 2 weeks ago

@ronkorland

did you reset the cache after editing the config file?

react-native start --reset-cache

ronkorland commented 2 weeks ago

@Mitch528 I try now with the reset cache but I still have the same error

vijaykharage7 commented 6 days ago

Hello @ronkorland did you happen to resolve this issue?

ronkorland commented 6 days ago

No