Documentation Index
Fetch the complete documentation index at: https://docs.larksh.com/llms.txt
Use this file to discover all available pages before exploring further.
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:| Attempt | Delay |
|---|---|
| 1 | ~1s |
| 2 | ~2s |
| 3 | ~4s |
| 4 | ~8s |
| 5 | ~16s |
| 6+ | ~30s (max) |
- 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
goOffline() / goOnline() | disconnect() | |
|---|---|---|
| Local cache | Preserved | Cleared |
| Subscriptions | Preserved, re-established on goOnline() | Removed |
| Pending writes | Preserved, sent on goOnline() | Cleared |
| Reconnect method | goOnline() | New instance + connect() |
| Use case | Temporary pause (background/foreground) | Permanent teardown |
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.

