Update a realm object inside an async function?




I recently started playing around with the Data Change Events functionality using node.js. I have ran into an issue which I cannot seem to solve in a clean matter.

I have a successfully setup a data change event and I have gotten a handle on the objects getting added to the realm instances. My logic is to look at the object and see if there is a missing (null) property. If so, I would like the server to find that missing information (async function) and update the object.

The problem I am seeing is that the realm that the object comes from becomes closed inside the async function as well as the object becomes invalidated (not able to update it). The dirty approach is to reopen the realm and search for the object again and then update it. Am I missing something here? I seen an example online using an old version of realm and this did not seem like an issue.


Update, I was not properly using async/await when setting up my change handler. My handler calls into other functions so had to make sure the await was being used in all following calls.