Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure outbox messages are sent in the correct order #3272

Merged
merged 4 commits into from
Jan 14, 2019

Conversation

borisyankov
Copy link
Contributor

@borisyankov borisyankov commented Jan 13, 2019

Fixes #3259

When sending more than one messages with poor connectivity there is
a likely an unwanted scenario that can happen: messages sent early might
fail to reach the server but later ones might succeed thus resulting in
the incorrect order.

Extracting the try-catch block outside the 'forEach' loop ensures that
a single failed message will also fail the sending of older messages.o

Fixes #3120

Try sending messages and keep retrying if sending fails.
Using progressiveTimeout we make sure we are not trying too often.

Thanks to state.session.outboxSending we are sure there will be
no two loops at the same time.

@borisyankov borisyankov force-pushed the send-in-order branch 2 times, most recently from fd0e73b to 041a8bd Compare January 14, 2019 03:02
Fixes zulip#3259.

When sending more than one message with poor connectivity there is a
likely and unwanted scenario that can happen: mesages sent early might
fail to reach the server but later ones might succeed thus resulting
in the incorrect order.

Extracting the try-catch block outside the 'forEach' loop ensures that
a single failed message will also fail the sending of later messages.

Better retry strategy is coming in a separate commit soon.
Extract the message sending code out of `trySendMessages` as a
separate function.  Rename the action to `sendOutbox`.

This is to facilitate retrying on failed send without reissuing
the `toggleOutboxSending` actions.

This also follows a well established convention for `try*` functions:
 * they handle an exception and do not throw
 * they return true/false depending on success/exception
Fixes zulip#3120.

Try sending messages and keep retrying if sending fails.
Using `progressiveTimeout` we make sure we are not trying too often.

Thanks to `state.session.outboxSending` we are sure there will be
no two loops at the same time.
Now that we are retrying on failed message send we are handling
all possible cases where we might end up with unsent messages:
* if message send fails immediately (we keep retrying)
* if the app was closed with unsent messages (we try again on
  next launch, inside `doInitialFetch` -- and keep retrying)

The connectivity change was a good heuristic with the imperfect
retry strategy but is not needed any more.
@gnprice gnprice merged commit 400f4ac into zulip:master Jan 14, 2019
@gnprice
Copy link
Member

gnprice commented Jan 14, 2019

Thanks @borisyankov ! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants