realm-js: Problems with Deleting Record with Realm for React Native
When I attempt to delete a record, my app instantly crashes and I cannot seem to catch the exception. From the MongoDB support team, it seems the context is being closed too soon. Any idea what is happening? This happens whether I use a listener or not.

Delete method:
const deleteList = (listId: string): void => {
const listRealm = realmRef.current;
const list = listRealm?.objectForPrimaryKey<List>("List", new ObjectId(listId));
try {
listRealm?.write<void>(() => {
if (list) {
listRealm?.delete(list);
}
})
} catch(error) {
console.log(error);
}
};
React Native 0.70
SDK: android vRealmJS/10.21.1 Platform Version: 31
MongoDB version 5.0.12
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 34 (5 by maintainers)
I think we have everything straightened out, for the most part. It seems that even if a listener is removed, it may not be completely removed. The code updates I made to handle this are as follows:
Yes, I will get what I can for you, as I can cause this exception to happen at will.
On Mon, Oct 10, 2022 at 9:32 AM Daniel Tabacaru @.***> wrote: