Realm.getInstanceAsync doesn't get called for the first time on android app

I have a ‘personalData’ in ‘datas’ table in Atlas. I am using flexible sync with subscription. The conditions for this issue are following:

  1. My app is synced and running fine.
  2. I quit the app
  3. I use realm-functions to deleteOne() the ‘personalData’ while the app is still closed.
  4. I now start the app, the 'Realm.getInstanceAsync(config, callback) never gets called — obviously as there is a conflict between local-realm and the remote-realm.
  5. I quit the app and restart it — now it works.

Any clue about why is it so and how to solve it?

Finally I found that if any modification is made on the database directly, it throws ‘Client Reset’ in case of ‘Flexible Sync’.

‘Flexible Sync’ works only till all changes are affected by the app. If you use Compass/Function/Webhook to modify the data, it requires ‘Client Reset’.

The error received by me on client reset was :
bad last integrated server version in upload progress (500180358788 > 17) (ProtocolErrorCode=209)

Another point to note is that if you use Flexible Sync, you are required to handle Client Reset manually.

Therefore my whole day or two is going to be spent in implementing Manual Reset, unless someone can explain the exact meaning of : " bad last integrated server version".

How to tell the local-realm that the data is deleted/modified in remote-realm and as the deletion/modification happened later than your timestamp, you should discard the local data and re-download remote data?