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

Aperta
#103 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@ChiragAgg5k ci sta già lavorando.

Dal 24/2/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

👟 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?
Lingua principale
Kotlin
Stelle
156
Fork
29
Merge medio
8h 49m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di appwrite/sdk-for-android

Tutte le issue di appwrite/sdk-for-android

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.