Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-1020

Flexible Sync: Creating objects without subscriptions pins flexible session as "pending"

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      How frequently does the bug occur?

      All the time

      Description

      Creating objects which isn't subscribed to, will experience the Promise returned from a call to realm.subscriptions.update will never resolve and the state won't ever be Completed.

      Stacktrace & log output

      Client logs

      This is the output from the logs:

       LOG  [SYNC:3]: Resolving 'ws.us-west-2.aws.realm.mongodb.com:443'
       LOG  [SYNC:3]: Connecting to endpoint '54.202.198.109:443' (1/1)
       LOG  [SYNC:4]: Connected to endpoint '54.202.198.109:443' (from '192.168.1.229:51221')
       LOG  [SYNC:3]: Connection[1]: Negotiated protocol version: 3
       LOG  [SYNC:4]: Connection[1]: Session[1]: Received: ERROR "Other session level error: error occurred while integrating uploaded changesets - request logs URL: https://realm.mongodb.com/groups/622659ec2df552008e84dee8/apps/62265e7c301d42db0288099a/logs?co_id=622f1b7789c9dd3ae981d9c2" (error_code=201, try_again=true)
       LOG  [SYNC:4]: Connection[1]: Disconnected
      

      Server logs

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      const Realm = require('realm');
      
      async function run() {
        const app = Realm.App.getApp('realmeats-nllpl');
        const credentials = Realm.Credentials.emailPassword(
          '...',
          'very-secure-password',
        );
        const user = await app.logIn(credentials);
        const config = {sync: {user, flexible: true}};
      
        console.log('Deleteing any previous file');
        Realm.deleteFile(config);
      
        console.log('Opening Realm');
        const realm = await Realm.open(config);
      
        console.log('Subscribing to restaurants');
        const restaurants = realm.objects('Restaurant');
        await realm.subscriptions.update(mutableSubs => {
          mutableSubs.add(restaurants);
        });
      
        console.log('Creating an order');
        const [firstRestaurant] = restaurants;
        realm.write(() => {
          realm.create('Order', {
            _id: new Realm.BSON.UUID(),
            ETA: new Date(),
            PlacedAt: new Date(),
            Guests: {},
            RestaurantId: firstRestaurant?._id,
            Restaurant: firstRestaurant,
            OwnerId: user.id,
            Status: 0,
          });
        });
      
        setInterval(() => {
          console.log({
            status: realm.subscriptions.state,
            error: realm.subscriptions.error,
          });
        }, 2000);
      
        console.log('Re-subscribing ...');
        await realm.subscriptions.update(mutableSubs => {
          mutableSubs.removeAll();
          mutableSubs.add(restaurants);
        });
      }
      
      run().catch(console.error);
      

      Version

      10.13.0

      What SDK flavour are you using?

      MongoDB Realm (i.e. Sync, auth, functions)

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      React Native iOS

      Build environment

      Which debugger for React Native: N/A

      Cocoapods version

      No response

            Assignee:
            daniel.tabacaru@mongodb.com Daniel Tabacaru
            Reporter:
            kraen.hansen@mongodb.com Kræn Hansen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: