How to handle the OtherSessionError and the consequent loss of data?

I have a realm app device sync setup which has a react native client which writes documents in the local database and then realm syncs it with atlas database. However, in a rare scenario the sync write fails with an error OtherSessionError. This deletes the document generate from local database as well. I am unable to debug why this error comes up. The device was successfully writing documents before this error and sync session restarted after this error and continued to write more documents. I did not find any documentation related to OtherSessionError. The error description is as follows:

integrating changesets failed: error creating new integration attempt: failed to get latest server version while integrating changesets: context canceled (ProtocolErrorCode=201)

Hi, that error should not result in the document being deleted locally. Device Sync is designed to handle these kinds of errors and retry them (both in the server and in the protocol between the client and the server). Normally when we see those errors it just means that the client disconnects, reconnects, re-uploads the changes, and then the data is persisted. Are you sure the document is being “deleted”? If so can you send the “request id” of the error in your “Logs” page of the app services UI and we can help take a look?


Hi Tyler,
Thank you for your response. The request id for the error log is 6404eaa54c509266ce223b8f. It looks like it was deleted because we are not able to find the associated document _id in the database.

Hi, if you look at this link (it is safe to post, noone else can view other than you and MongoDB employees) you can see the error happen, the client reconnect, and upload the proper document (can see the _id in the write summary section of the log): App Services

In fact, if you follow it through, we can see why this document doesnt exist: (link was hard to show the exact events)

Here is a more complete timeline: App Services

It looks like someone deleted the document in MongoDB. My hunch is that the trigger you have setup did it, but I can’t be certain without looking in more detail.

Let me know if this sounds right to you, but it sounds like the error has nothing to do with the document disappearing as that is just a coincidence of someone/something deleting the document in MongoDB at roughly the same time.


Yes, you are correct. The document write was attempted again and was successful. We are deleting it in the trigger and rewriting into another collection. Thank you for your support.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.