Realtime messages can come out of order (and in fact are processed in parallel)

Đang mở
#103 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@ChiragAgg5k đang làm issue này rồi.

Từ ngày 24/2/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

👟 Reproduction steps
  1. In Kotlin, create a Realtime subscription.
  2. Trigger multiple messages (for example, createOperations and create multiple items at the same time)
  3. Observe they are not ordered, but are processed in parallel.

In my code, I used a callbackFlow to convert the callback to a flow, so I essentially processed them sequentially, but due to the callback, they don't necessarily enter the queue in order.

Note: this does not happen all the time, so repeated attempts to reproduce may be required before it occurs. Best way is to ensure multiple updates come at the same time and are ordered in a fashion that's easy to notice (such as an increasing text field or something).

Note in Realtime.kt, AppwriteWebSocketListener onMessage, when it receives a message, it performs launch(IO) to handle the response event. This means each message gets scheduled to run in parallel, which means the messages are not serialized per subscriber.

👍 Expected behavior

I expect to get my callback called in the order of messages I get from the server, and not have parallel callbacks, as I might reasonably expect updates to be processed in order.

Alternatively and perhaps better, I would like to have the API expose the server messages as a Flow<RealtimeResponse> instead of a callback model.

👎 Actual Behavior

Actual behavior is the messages can come in arbitrary order. Often they're in order but not always. Here's some example logging output:
2026-01-04 20:44:48.717 22217-22295 D Got an item id=A
2026-01-04 20:44:48.722 22217-29657 D Got an item id=C
2026-01-04 20:44:48.725 22217-22291 D Got an item id=B

Note the process ID is the same 22217 but the thread id is different for each message.

For reference, in another (web) client, I got:

A $createdAt=2026-01-05T04:44:50.074+00:00 timestamp=2026-01-05T04:44:50.095+00:00
B $createdAt=2026-01-05T04:44:50.078+00:00 timestamp=2026-01-05T04:44:50.100+00:00
C $createdAt=2026-01-05T04:44:50.078+00:00 timestamp=2026-01-05T04:44:50.105+00:00

🎲 Appwrite version

Version 1.8.x

💻 Operating system

Linux

🧱 Your Environment

This is using the Android Kotlin library io.appwrite:sdk-for-android:11.4.0

👀 Have you spent some time to check if this issue has been raised before?
  • I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
Ngôn ngữ chính
Kotlin
Star
156
Fork
29
Merge trung bình
8 giờ 49 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của appwrite/sdk-for-android

Tất cả issue của appwrite/sdk-for-android

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.