Crashed on recyclerview

Scenario: creating a record from mobile and then syncing the record with MongoDB altas then update it on web side on same time I am on same list so when I click on list item it is crashing

Fatal Exception: java.lang.IllegalStateException Access to invalidated List object

io.realm.internal.OsList.nativeSize (OsList.java) io.realm.internal.OsList.size (OsList.java:248) io.realm.ManagedListOperator.size (ManagedListOperator.java:73) io.realm.RealmList.size (RealmList.java:597) com.reach52.healthcare.ui.medicine.adapter.MedicineSubOrderItemAdapter.getItemCount (MedicineSubOrderItemAdapter.kt:53) androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1 (RecyclerView.java:4044) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:870)

override fun getItemCount(): Int = medicineItemList.size  // Crashing on this line

i have tried the .isValid() object but i am unable to use that on the above function

@kunal_gharate : Can you send some more details like GitHub repo(which would be great) or how are you accessing data and passing to adapter, if you have figured out how to fix the issue.