Offline and reconnection
Network connections drop. Users go through tunnels, switch between Wi-Fi and cellular, or temporarily lose signal. The Lark SDK handles all of this automatically so your app stays functional.Automatic reconnection
When a connection drops unexpectedly, the SDK reconnects automatically using exponential backoff with jitter:
Jitter adds a random factor so that thousands of clients don’t all reconnect at the same instant after a server restart.
When the connection is re-established:
- All active subscriptions are automatically re-registered.
- Any pending writes that were queued while offline are sent to the server.
- Your
onConnectcallbacks fire again.
Manual control
goOffline() and goOnline()
Pause and resume the connection manually. This preserves your local cache and subscription registrations.
goOffline():
- Writes are queued locally and sent when you go back online.
- Subscriptions still reflect the last known cached data.
- No network traffic occurs.
disconnect()
Fully tears down the connection and clears everything: cache, subscriptions, pending writes. Use this when you’re completely done with the database.
Comparison
Pending writes
When the SDK is offline, writes queue up locally. You can inspect and manage this queue.db.hasPendingWrites()
Returns true if there are writes waiting to be sent to the server:
db.getPendingWriteCount()
Returns the number of pending writes:
db.clearPendingWrites()
Discards all pending writes. Use this carefully, because those writes will be lost permanently.
Connection status
The SDK provides a special path.info/connected that reflects the current connection state. This is useful for showing online/offline indicators in your UI.

