question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Realm initial sync stucking on 'Pending' when a collection is big

See original GitHub issue

I have a database of ~250mb. When I open a synced realm on the client I subscribe to a class of objects and I add a listener to wait for the sync to complete.

My problem is that, on Android simulator, the subscription doesn’t go on and the last state I can track is ‘Pending’.

This issue seems to appears only on Android Emulator but I had the same issue, with a ~1Gb database also on a Galaxy S9. I’m worried that this isn’t the best way to do initial sync but I can’t find any solutions provided by Realm to such a scenario.

Code Sample

await this.susbscribeAndSyncTo(this.realm_instance.objects("Cliente"), "Cliente") // This is where the sync begin

static susbscribeAndSyncTo = async (object, object_name) => {

        var subscription = object.subscribe()

        return new Promise((resolve, reject) => {
            subscription.addListener((subscription, state) => {
                if (this.checkSubscriptionState(state, object_name)) {
                    try {
                        subscription.removeAllListeners()
                    } catch (e) {
                        console.log(e.message)
                    }
                    resolve(true);
                }
            })
        });

    }
    static checkSubscriptionState = (state, object_type) => {

        switch (state) {
            case Realm.Sync.SubscriptionState.Creating:
                logIfDebug(this.DEBUG,"Creo la subscription per", object_type)
                // The subscription has not yet been written to the Realm
                break;
            case Realm.Sync.SubscriptionState.Pending:
                logIfDebug(this.DEBUG,"Attendo l'arrivo dei dati", object_type)
                // The subscription has been written to the Realm and is waiting
                // to be processed by the server
                break;
            case Realm.Sync.SubscriptionState.Complete:
                logIfDebug(this.DEBUG,"I dati sono sincronizzati con il server", object_type)
                // The subscription has been processed by the server and all objects
                // matching the query are in the local Realm
                return true

                break;
            case Realm.Sync.SubscriptionState.Invalidated:
                logIfDebug(this.DEBUG,"La sottoscrizione ai dati è stata invalidata", object_type)
                // The subscription has been removed
                break;
            case Realm.Sync.SubscriptionState.Error:
                logIfDebug(this.DEBUG,"C'è stato un errore nella sincronizzazione con il server", object_type)
                break;

            default:
                logIfDebug(this.DEBUG,"Mmmm")
                break;
        }

        return false

    }

Version of Realm and Tooling

  • Realm JS SDK Version: 2.29.2
  • Node or React Native: 0.60
  • Client OS & Version: Android Emulator
  • Which debugger for React Native: ?/None

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cbushcommented, Sep 26, 2019

It seems not all SDKs have this functionality yet. I can update the JS code examples for now (see draft), but updating the general docs will just make it more confusing. I will hold off for now.

0reactions
knethcommented, Oct 31, 2019

@cbush It has been released in Realm Cocoa v3.16.0 and Realm Java v5.13.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Starting sync stucks on "…coping data" and never finishs
I have small amount of data in Atlas: 3 collections: COLLECTION SIZE: ... When starting sync it gets stuck on “…coping data” and...
Read more >
How to fix OneDrive is stuck on sync pending - YouTube
Onedrive sync your data to the cloud but sometime sync stuck due to errors. you can reset onedrive via command line. please see...
Read more >
WebLogic Server Known and Resolved Issues
Change Request Number Found In Fixed In CR200627 9.0 CR208373 9.0 9.2 CR214481 9.0 9.2
Read more >
Realm: Notification after initial sync - Stack Overflow
I am using the Realm Object Server and the first time a user opens my app a large set of data is synched...
Read more >
BIG-IP 15.1.2.1 Fixes and Known Issues - AskF5 - F5 Networks
921421-3, 4-Minor, iRule support to get/set UDP's Maximum Buffer Packets ... 737098-1, 3-Major, ASM Sync does not work when the configsync IP address...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found