realm / realm-js

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

Bug on nested array linking objects update, (bug not happening on Realm 12.2.1) #6889

Open angelos3lex opened 1 week ago

angelos3lex commented 1 week ago

How frequently does the bug occur?

Always

Description

So we have to update to RN 0.74.5 (from 0.72) and we were on 12.2.1 realm version. Unfortunately, keeping same realm version, makes the app block on white screen, and through logcat I can see it's just saying " Building an exports object", but never proceeds. So, I tried with 12.12.1 and 12.13.1 realm versions, which do not have this problem and everything goes smoothly, except from one use case.

I have a parent object Participant which has a subTable array of ParticipantMeta objects. ParticipantMeta are linking objects to the parent Participant.

When i create a Participant object with some metas, it's correctly added on the db. When i query it, and re-add it using realm.create with Realm.UpdateMode.ALL, without any change at all, the meta list array becomes empty.

I have created a reproducible "minimal" repo that you can see on the logs the problem.

Update to RN 0.74 is crucial as we need to target api 34, and be able to release on playstore. Currently, this is our only blocker.

Stacktrace & log output

no crash. Only from the logs we can see that before updating the object we have full array and after the update, the array of the subTable is emptied.

Can you reproduce the bug?

Always

Reproduction Steps

https://github.com/angelos3lex/Realm-js-12.13.1-bug-repro Check this repo ^ (Mainly App.tsx onPress of the button is where the whole logic begins.)

PS: Didn't test the reproducible example on iOS, but on my real case app it's also happening on iOS.

Version

12.12.1, 12.13.1

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

android, iOS, realm 12.12+, RN 0.74.5

Build environment

no debugger

Cocoapods version

didn't test the reproducible example on iOS, but on my real case app it's also happening on iOS.

sync-by-unito[bot] commented 1 week ago

➤ PM Bot commented:

Jira ticket: RJS-2903

angelos3lex commented 1 week ago

Bonus on above reproducible repo: If you change realm version to 12.2.1, you will be able to reproduce the freezing white screen after metro loads. By logcat I can just see the following logs:

JSRealm                 com.realmbrokenproject               V  setDefaultRealmFileDirectory
JSRealm                 com.realmbrokenproject               D  Absolute path: /data/data/com.realmbrokenproject/files
JSRealm                 com.realmbrokenproject               V  install
JSRealm                 com.realmbrokenproject               V  Building an exports object