mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 00:25:03 +08:00
[client-app] Fix delta streaming connection retries
Summary: Previously, every time our NylasLongConnection changed its status to `connected`, we would reset our backoff scheduler, assuming that every time our status changed to `connected` it meant that we would not receive any errors. However, if our backend is down or overloaded (or returning 401s like in our recent outage), we would do the following: 1. Establish connection, change status to `connected` 2. Reset backoff scheduler 3. Receive error 4. Close connection 5. Schedule next retry using backoff scheduler. Delay will be 1s or less, because scheduler was reset in 2. 6. Retry after delay, 7. Repeat from 1., ad infinitum This caused us to consistantly hammer our servers and render our exponential backoff useless. This commit makes it so we conly reset the backoff scheduler when we actually receive deltas, and increments the max backoff to 10 minutes Test Plan: run against local n1Cloud, manually return 401s from the api, verify that we didn't backoff at all before this diff, verify that we backoff correctly after this diff Reviewers: mark, spang, halla Reviewed By: mark, spang, halla Differential Revision: https://phab.nylas.com/D4401
This commit is contained in:
parent
e8957b787e
commit
07d576d5f4
1 changed files with 1 additions and 2 deletions
|
@ -11,7 +11,7 @@ import OnlineStatusStore from '../flux/stores/online-status-store'
|
|||
import NylasLongConnection from '../flux/nylas-long-connection'
|
||||
|
||||
|
||||
const MAX_RETRY_DELAY = 5 * 60 * 1000; // 5 minutes
|
||||
const MAX_RETRY_DELAY = 10 * 60 * 1000;
|
||||
const BASE_RETRY_DELAY = 1000;
|
||||
|
||||
class DeltaStreamingConnection {
|
||||
|
@ -124,7 +124,6 @@ class DeltaStreamingConnection {
|
|||
this._writeStateDebounced();
|
||||
const {Closed, Connected} = NylasLongConnection.Status
|
||||
if (status === Connected) {
|
||||
this._backoffScheduler.reset()
|
||||
Actions.updateAccount(this._account.id, {
|
||||
n1CloudState: Account.N1_CLOUD_STATE_RUNNING,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue