discordie icon indicating copy to clipboard operation
discordie copied to clipboard

Text Que out of order

Open Ryu945 opened this issue 8 years ago • 4 comments

Occasionally, the text que will get out of order. For example, out of 100 messages sent in a row, two neighbouring messages will be swapped with each other once. This happens consistently.

Ryu945 avatar Aug 04 '16 23:08 Ryu945

If you mean this is happening when sending messages - Discord uses snowflakes which is a distributed system which means order within couple tens milliseconds is not guaranteed.

See more here: https://github.com/twitter/snowflake/tree/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231

We have a number of API resources that assume an ordering (they let you look things up "since this id").

However, as a result of a large number of asynchronous operations, we already don't guarantee in-order delivery.

We can guarantee, however, that the id numbers will be k-sorted (references: http://portal.acm.org/citation.cfm?id=70413.70419 and http://portal.acm.org/citation.cfm?id=110778.110783) within a reasonable bound (we're promising 1s, but shooting for 10's of ms).

qeled avatar Aug 04 '16 23:08 qeled

Is there a way to fix it like put a required delay between every message sent to lower the probability/stop this from happening?

Ryu945 avatar Aug 06 '16 16:08 Ryu945

@Ryu945 if it's imperative it does not happen you could always manually add a setTimeout to your 2nd message or send it on the callback of the first message. These could both become harder to implement in a more complex system though.

macdja38 avatar Aug 09 '16 06:08 macdja38

Thanks for the information. I might have to add that. I posted here because I thought achieving correct message order in synchronus code was something the API would be interested in programming in.

Ryu945 avatar Aug 15 '16 19:08 Ryu945