Sync connection automatically disconnects after a while

I am trying to connect to my DB as an app user, but the sync connection disconnects automatically after a few seconds it seems. Here’s a minimal reproducible example.

class Person extends Realm.Object {
  static schema = dummyCollectionSchema;
}
class PersonInfo extends Realm.Object {
  static schema = dummyCollection_infoSchema;
}

async function connect() {
  const app = new Realm.App({ id: "application", timeout: 10000 });
  const credentials = Realm.Credentials.emailPassword("usr", "pwd");
  const user = await app.logIn(credentials);

  const config = {
    schema: [Person, PersonInfo],
    sync: {
      user,
      flexible: true,
      initialSubscriptions: {
        update: (subs, realm) => {
          subs.add(realm.objects(Person), { name: "Persons" });
        },
      },
    },
  };
  return await Realm.open(config);
}

async function run() {
  const realm = await connect();

  console.log(`>>> Connected: ${realm.syncSession.isConnected()}`);
  // If I write a document to my collection here, it gets synced to Atlas

  // wait 10 seconds
  await new Promise(r => setTimeout(r, 10000));  
  console.log(`>>> Connected: ${realm.syncSession.isConnected()}`);
  // If I write a document  here, it does not appear in Atlas. It appears the next time I run the script though.
}

run().catch(err => console.error(`${err}`));

I do not get any errors, but the second console.log says Connected: false. If I write to the database, it always writes to the local realm. But anything that is written after a few seconds of connection does not get synced (gets synced the next time I run my code). What am I doing wrong here?


TL;DR

Here's the output with `Realm.setLogLevel("trace")`
[detail] DB: 39400 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[detail] DB: 39400 Thread 140081426462720: DB closed
[detail] DB: 39400 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: Tr 15978: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Start read 17876: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 17876
[trace] DB: 39400 Thread 140081426462720: Start read 17876: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[debug] DB: 39400 Thread 140081426462720: Query count: 'state != 2', limit = -1
[debug] DB: 39400 Thread 140081426462720: Query matches: 1, Duration: 11 us
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[debug] DB: 39400 Thread 140081426462720: Query find all: 'state != 2', limit = -1
[debug] DB: 39400 Thread 140081426462720: Query found: 1, Duration: 3 us
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Tr 17876: Already on version: 26
[trace] DB: 39400 Thread 140081426462720: Start read 18977: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 18977
[trace] DB: 39400 Thread 140081426462720: Start read 18977: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: Tr 18977: Already on version: 26
[debug] DB: 39400 Thread 140081426462720: Query count: 'state == 2', limit = -1
[debug] DB: 39400 Thread 140081426462720: Query matches: 0, Duration: 2 us
[trace] DB: 39400 Thread 140081426462720: Tr 18977: Already on version: 26
[debug] DB: 39400 Thread 140081426462720: Query count: 'state == 2', limit = -1
[debug] DB: 39400 Thread 140081426462720: Query matches: 0, Duration: 2 us
[trace] DB: 39400 Thread 140081426462720: End transaction 18977
[trace] DB: 39400 Thread 140081426462720: End transaction 17876
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[detail] DB: 39400 Thread 140081426462720: DB closed
[detail] DB: 39400 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[trace] DB: 39400 Thread 140081426462720: Start read 15978: 26 ref 6040
[trace] DB: 39400 Thread 140081426462720: End transaction 15978
[detail] DB: 39400 Thread 140081426462720: DB closed
[debug] App: update_hostname: https://eu-central-1.aws.realm.mongodb.com | wss://ws.eu-central-1.aws.realm.mongodb.com
[debug] App: log_in_with_credentials: app_id: application
[debug] App: version info: platform: Linux  version: 6.2.0-34-generic - sdk: JS - sdk version: 12.2.1 - core version: 13.22.0
[debug] App: request location: https://eu-central-1.aws.realm.mongodb.com/api/client/v2.0/app/application/location
[debug] App: update_hostname: https://eu-central-1.aws.realm.mongodb.com | wss://ws.eu-central-1.aws.realm.mongodb.com
[detail] DB: 20669 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 26 ref 6040
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 26 ref 6040
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 26 ref 6040
[debug] DB: 20669 Thread 140081426462720: Query find all: 'identity == "651ebd8f56f6ff579c132fcf"', limit = -1
[debug] DB: 20669 Thread 140081426462720: Query found: 1, Duration: 10 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Acquired write lock in 319 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Already on version: 26
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Promote to write: 26 -> 26
[debug] DB: 20669 Thread 140081426462720: Initiate commit version: 27
[debug] DB: 20669 Thread 140081426462720: Commit of size 2456 done in 6453 us ref 7776
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[detail] DB: 20669 Thread 140081426462720: DB closed
[debug] App: do_authenticated_request: GET https://eu-central-1.aws.realm.mongodb.com/api/client/v2.0/auth/profile
[trace] DB: 20669 Thread 140069419611712: acquire writemutex
[trace] DB: 20669 Thread 140069419611712: writemutex acquired
[trace] DB: 20669 Thread 140069419611712: writemutex released
[detail] DB: 20669 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 27 ref 7776
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 27 ref 7776
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 27 ref 7776
[debug] DB: 20669 Thread 140081426462720: Query find all: 'identity == "651ebd8f56f6ff579c132fcf"', limit = -1
[debug] DB: 20669 Thread 140081426462720: Query found: 1, Duration: 11 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Acquired write lock in 176 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Already on version: 27
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Promote to write: 27 -> 27
[debug] DB: 20669 Thread 140081426462720: Initiate commit version: 28
[debug] DB: 20669 Thread 140081426462720: Commit of size 1552 done in 2655 us ref 3984
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Acquired write lock in 29 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Already on version: 28
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Promote to write: 28 -> 28
[debug] DB: 20669 Thread 140081426462720: Initiate commit version: 29
[debug] DB: 20669 Thread 140081426462720: Commit of size 328 done in 1616 us ref 4144
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[detail] DB: 20669 Thread 140081426462720: DB closed
[detail] DB: 20669 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 29 ref 4144
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 29 ref 4144
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 29 ref 4144
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Acquired write lock in 78 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Already on version: 29
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Promote to write: 29 -> 29
[debug] DB: 20669 Thread 140081426462720: Initiate commit version: 30
[debug] DB: 20669 Thread 140081426462720: Commit of size 328 done in 2287 us ref 4304
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[detail] DB: 20669 Thread 140081426462720: DB closed
[detail] DB: 20669 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 30 ref 4304
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 30 ref 4304
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 30 ref 4304
[debug] DB: 20669 Thread 140081426462720: Query find all: 'identity == "651ebd8f56f6ff579c132fcf"', limit = -1
[debug] DB: 20669 Thread 140081426462720: Query found: 1, Duration: 6 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Acquired write lock in 75 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Already on version: 30
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Promote to write: 30 -> 30
[debug] DB: 20669 Thread 140081426462720: Initiate commit version: 31
[debug] DB: 20669 Thread 140081426462720: Commit of size 328 done in 2950 us ref 4464
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[detail] DB: 20669 Thread 140081426462720: DB closed
[detail] DB: 20669 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 31 ref 4464
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 31 ref 4464
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 31 ref 4464
[debug] DB: 20669 Thread 140081426462720: Query find all: 'identity == "651ebd8f56f6ff579c132fcf"', limit = -1
[debug] DB: 20669 Thread 140081426462720: Query found: 1, Duration: 6 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Acquired write lock in 78 us
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Already on version: 31
[trace] DB: 20669 Thread 140081426462720: Tr 18977: Promote to write: 31 -> 31
[debug] DB: 20669 Thread 140081426462720: Initiate commit version: 32
[debug] DB: 20669 Thread 140081426462720: Commit of size 328 done in 2308 us ref 7752
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[detail] DB: 20669 Thread 140081426462720: DB closed
[detail] DB: 20669 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/651ebd8f56f6ff579c132fcf/flx_sync_default.realm
[trace] Default event loop: start()
[info] Realm sync client ([realm-core-13.22.0])
[debug] Supported protocol versions: 2-10
[info] Platform: Linux Linux 6.2.0-34-generic #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 13:12:03 UTC 2 x86_64
[debug] Build mode: Release
[debug] Config param: one_connection_per_session = false
[debug] Config param: connect_timeout = 120000 ms
[debug] Config param: connection_linger_time = 30000 ms
[debug] Config param: ping_keepalive_period = 60000 ms
[debug] Config param: pong_keepalive_timeout = 120000 ms
[debug] Config param: fast_reconnect_limit = 60000 ms
[debug] Config param: disable_upload_compaction = false
[debug] Config param: disable_sync_to_disk = false
[debug] Config param: reconnect backoff info: max_delay: 300000 ms, initial_delay: 1000 ms, multiplier: 2
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 10 ref 8920
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 10 ref 8920
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140081426462720: Start read 18977: 10 ref 8920
[debug] DB: 20669 Thread 140081426462720: Query find all: '(state == 3 or state == 6)', limit = -1
[debug] DB: 20669 Thread 140081426462720: Query found: 1, Duration: 17 us
[debug] DB: 20669 Thread 140081426462720: Query find all: 'state == 6', limit = -1
[debug] DB: 20669 Thread 140081426462720: Query found: 0, Duration: 2 us
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
[trace] DB: 20669 Thread 140069419611712: acquire writemutex
[trace] DB: 20669 Thread 140069419611712: writemutex acquired
[trace] DB: 20669 Thread 140069419611712: writemutex released
[trace] DB: 20669 Thread 140069419611712: acquire writemutex
[trace] DB: 20669 Thread 140069419611712: writemutex acquired
[trace] DB: 20669 Thread 140069419611712: writemutex released
[trace] DB: 20669 Thread 140069419611712: acquire writemutex
[trace] DB: 20669 Thread 140069419611712: writemutex acquired
[trace] DB: 20669 Thread 140069419611712: writemutex released
[trace] DB: 20669 Thread 140069419611712: acquire writemutex
[trace] DB: 20669 Thread 140069419611712: writemutex acquired
[trace] DB: 20669 Thread 140069419611712: writemutex released
[trace] DB: 20669 Thread 140069419611712: acquire writemutex
[trace] DB: 20669 Thread 140069419611712: writemutex acquired
[trace] DB: 20669 Thread 140069419611712: writemutex released
[trace] Default event loop: thread running
[trace] Default event loop: service run
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[info] Connection[1]: Session[1]: Binding '/home/teshan/scripts/node-stuff/mongodb-realm/application/651ebd8f56f6ff579c132fcf/flx_sync_default.realm' to ''
[debug] Connection[1]: Session[1]: Activating
[info] Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, client reset = false
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[debug] Connection[1]: Session[1]: client_file_ident = 19, client_file_ident_salt = 5735865225673926823
[debug] Connection[1]: Session[1]: last_version_available  = 10
[debug] Connection[1]: Session[1]: progress_download_server_version = 1
[debug] Connection[1]: Session[1]: progress_download_client_version = 0
[debug] Connection[1]: Session[1]: progress_upload_server_version = 0
[debug] Connection[1]: Session[1]: progress_upload_client_version = 0
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[debug] Connection[1]: Session[1]: Progress handler called, downloaded = 197, downloadable(total) = 197, uploaded = 0, uploadable = 0, reliable_download_progress = false, snapshot version = 10
[info] Connection[1]: Connecting to 'wss://ws.eu-central-1.aws.realm.mongodb.com:443/api/client/v2.0/app/application/realm-sync'
[debug] WebSocket::Websocket()
[detail] Resolving 'ws.eu-central-1.aws.realm.mongodb.com:443'
[detail] Connecting to endpoint '35.157.33.91:443' (1/1)
[info] Connected to endpoint '35.157.33.91:443' (from '192.168.50.181:49980')
[debug] WebSocket::initiate_client_handshake()
[trace] HTTP request =
GET /api/client/v2.0/app/application/realm-sync?baas_at=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiYWFzX2RldmljZV9pZCI6IjY1MjY1NmQ5YWUyMGJmZDkwM2EyM2U2MSIsImJhYXNfZG9tYWluX2lkIjoiNjUxZTdkZTU3Yzk5YzFlMTlmNWZjZjRhIiwiZXhwIjoxNjk3MDEzMjE3LCJpYXQiOjE2OTcwMTE0MTcsImlzcyI6IjY1MjY1NmQ5YWUyMGJmZDkwM2EyM2U2ZSIsInN0aXRjaF9kZXZJZCI6IjY1MjY1NmQ5YWUyMGJmZDkwM2EyM2U2MSIsInN0aXRjaF9kb21haW5JZCI6IjY1MWU3ZGU1N2M5OWMxZTE5ZjVmY2Y0YSIsInN1YiI6IjY1MWViZDhmNTZmNmZmNTc5YzEzMmZjZiIsInR5cCI6ImFjY2VzcyIsInVzZXJfZGF0YSI6eyJfaWQiOiI2NTFlYjdkYTBmMjhjMDU1YTExNGIwZTciLCJuYW1lIjoiVGVzaGFuIiwidXNlcklEIjoiNjUxZWJkOGY1NmY2ZmY1NzljMTMyZmNmIiwib3JncyI6WyJBIl19fQ.tAxuGyDQKqribzBIPS-onNYe0P4AkxXsv_-XRe-SI6Q HTTP/1.1
Host: ws.eu-central-1.aws.realm.mongodb.com
Connection: Upgrade
Sec-WebSocket-Key: P9QrN4Wz7222ZDdbBfevSQ==
Sec-WebSocket-Protocol: com.mongodb.realm-query-sync#10, com.mongodb.realm-query-sync#9, com.mongodb.realm-query-sync#8, com.mongodb.realm-query-sync#7, com.mongodb.realm-query-sync#6, com.mongodb.realm-query-sync#5, com.mongodb.realm-query-sync#4, com.mongodb.realm-query-sync#3, com.mongodb.realm-query-sync#2
Sec-WebSocket-Version: 13
Upgrade: websocket
User-Agent: RealmSync/13.22.0 (Linux Linux 6.2.0-34-generic #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 13:12:03 UTC 2 x86_64) RealmJS/12.2.1 (v6.2.0-34-generic)


[debug] WebSocket::handle_http_response_received()
[trace] HTTP response = HTTP/1.1 101 Switching Protocols
cache-control: no-cache, no-store, must-revalidate
connection: Upgrade
date: Wed, 11 Oct 2023 08:03:37 GMT
sec-websocket-accept: CPffXCtDJh11OV7OggpCkXu4hC4=
sec-websocket-protocol: com.mongodb.realm-query-sync#10
server: mdbws
strict-transport-security: max-age=31536000; includeSubdomains;
upgrade: websocket
vary: Origin
x-appservices-request-id: 652656daab22e8cc093b1621
x-envoy-decorator-operation: baas-sync.baas-prod.svc.cluster.local:8087/*
x-frame-options: DENY


[detail] Connection[1]: Negotiated protocol version: 10
[info] Connection[1]: Connected to app services with request id: "652656daab22e8cc093b1621"
[debug] Connection[1]: Will emit a ping in 21138 milliseconds
[debug] Connection[1]: Session[1]: Sending: BIND(session_ident=1, need_client_file_ident=false, is_subserver=false, json_data="{"sessionReason":0}")
[trace] DB: 20669 Thread 140069419611712: Start frozen 805: 10 ref 8920
[debug] DB: 20669 Thread 140069419611712: Query find all: '(state == 3 or state == 6)', limit = -1
[debug] DB: 20669 Thread 140069419611712: Query found: 1, Duration: 14 us
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[debug] Connection[1]: Session[1]: Sending: IDENT(client_file_ident=19, client_file_ident_salt=5735865225673926823, scan_server_version=1, scan_client_version=0, latest_server_version=1, latest_server_version_salt=0, query_version=0, query_size=2, query="{}")
[debug] Connection[1]: Session[1]: Sending: MARK(request_ident=2)
[debug] Connection[1]: Session[1]: Received: MARK(request_ident=2)
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[debug] DB: 20669 Thread 140069419611712: Query find all: 'version > 0 and (state == 1 or state == 2) and snapshot_version > -1', limit = -1
[debug] DB: 20669 Thread 140069419611712: Query found: 0, Duration: 15 us
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[debug] DB: 20669 Thread 140069419611712: Query find all: 'version > 0 and (state == 1 or state == 2) and snapshot_version > -1', limit = -1
[debug] DB: 20669 Thread 140069419611712: Query found: 0, Duration: 7 us
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[debug] Connection[1]: Session[1]: Sending: UPLOAD(progress_client_version=10, progress_server_version=1, locked_server_version=1, num_changesets=0)
[detail] DB: 39400 Thread 140081426462720: Open file: /home/teshan/scripts/node-stuff/mongodb-realm/application/server-utility/metadata/sync_metadata.realm
[trace] DB: 39400 Thread 140081426462720: Start read 18977: 32 ref 7752
[trace] DB: 39400 Thread 140081426462720: End transaction 18977
[trace] DB: 39400 Thread 140081426462720: Start read 18977: 32 ref 7752
[trace] DB: 39400 Thread 140081426462720: End transaction 18977
[trace] DB: 39400 Thread 140081426462720: Start read 18977: 32 ref 7752
[debug] DB: 39400 Thread 140081426462720: Query find all: 'identity == "651ebd8f56f6ff579c132fcf"', limit = -1
[debug] DB: 39400 Thread 140081426462720: Query found: 1, Duration: 7 us
[trace] DB: 39400 Thread 140081426462720: Tr 18977: Acquired write lock in 229 us
[trace] DB: 39400 Thread 140081426462720: Tr 18977: Already on version: 32
[trace] DB: 39400 Thread 140081426462720: Tr 18977: Promote to write: 32 -> 32
[debug] DB: 39400 Thread 140081426462720: Initiate commit version: 33
[debug] DB: 39400 Thread 140081426462720: Commit of size 328 done in 7385 us ref 3888
[trace] DB: 39400 Thread 140081426462720: End transaction 18977
[detail] DB: 39400 Thread 140081426462720: DB closed
[trace] DB: 20669 Thread 140081426462720: Start frozen 18977: 10 ref 8920
[trace] DB: 20669 Thread 140081426462720: End transaction 18977
>>> Connected: true
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[trace] DB: 20669 Thread 140069419611712: Start read 805: 10 ref 8920
[debug] DB: 20669 Thread 140069419611712: Query find all: 'version > 0 and (state == 1 or state == 2) and snapshot_version > 9', limit = -1
[debug] DB: 20669 Thread 140069419611712: Query found: 0, Duration: 9 us
[trace] DB: 20669 Thread 140069419611712: End transaction 805
[trace] DB: 39400 Thread 140069394433600: acquire writemutex
[trace] DB: 39400 Thread 140069394433600: writemutex acquired
[trace] DB: 39400 Thread 140069394433600: writemutex released
[debug] Waiting for 1 connections to drain
[trace] Default event loop teardown
[trace] Default event loop: stop()
[trace] Default event loop: wait for stop
[debug] Connection[1]: Session[1]: Initiating deactivation
[debug] Connection[1]: Session[1]: Sending: UNBIND
[debug] Draining connections during sync client shutdown
[debug] Connection[1]: Session[1]: Deactivation completed
[debug] Connection[1]: Force closed idle connection
[debug] Connection[1]: Destroying connection object
[trace] Default event loop: thread exiting
>>> Connected: false

Hey, more than 5 months after I am also experiencing this issue. I wonder why nobody answered on this where this seems to be very basic in practice. I am not doing anything more than the documentation.

I found a solution. Hope it helps.

Thank you @tsj_cmr ! Looks like this solution works using your code snippet combined with the solution. What’s weird is in my case the user object was already global… oh well… as long as it works :slight_smile:

1 Like