1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

When disconnected from Aphlict after a successful connection, retry the first reconnect right away

Summary:
Fixes T12567. We currently retry after 2s, 4s, 8s, 16s, ...

If we connected cleanly once, retry the first time right away. There are a bunch of reasonable cases where this will work fine and we don't need to wait. Then we fall back: 0s, 2s, 4s, 8s, ...

Test Plan: {F4911905}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12567

Differential Revision: https://secure.phabricator.com/D17706
This commit is contained in:
epriestley 2017-04-17 13:20:48 -07:00
parent 1212047843
commit 8fdc1bff5f
2 changed files with 19 additions and 9 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'a34d59bd', 'conpherence.pkg.css' => 'a34d59bd',
'conpherence.pkg.js' => '5f86c17d', 'conpherence.pkg.js' => '5f86c17d',
'core.pkg.css' => '959330a2', 'core.pkg.css' => '959330a2',
'core.pkg.js' => 'd7ca5b9a', 'core.pkg.js' => 'cb50c410',
'darkconsole.pkg.js' => 'a2faee86', 'darkconsole.pkg.js' => 'a2faee86',
'differential.pkg.css' => '90b30783', 'differential.pkg.css' => '90b30783',
'differential.pkg.js' => 'ddfeb49b', 'differential.pkg.js' => 'ddfeb49b',
@ -245,7 +245,7 @@ return array(
'rsrc/externals/javelin/lib/Sound.js' => '949c0fe5', 'rsrc/externals/javelin/lib/Sound.js' => '949c0fe5',
'rsrc/externals/javelin/lib/URI.js' => 'c989ade3', 'rsrc/externals/javelin/lib/URI.js' => 'c989ade3',
'rsrc/externals/javelin/lib/Vector.js' => '2caa8fb8', 'rsrc/externals/javelin/lib/Vector.js' => '2caa8fb8',
'rsrc/externals/javelin/lib/WebSocket.js' => '0c4969d6', 'rsrc/externals/javelin/lib/WebSocket.js' => '3ffe32d6',
'rsrc/externals/javelin/lib/Workflow.js' => '1e911d0f', 'rsrc/externals/javelin/lib/Workflow.js' => '1e911d0f',
'rsrc/externals/javelin/lib/__tests__/Cookie.js' => '5ed109e8', 'rsrc/externals/javelin/lib/__tests__/Cookie.js' => '5ed109e8',
'rsrc/externals/javelin/lib/__tests__/DOM.js' => 'c984504b', 'rsrc/externals/javelin/lib/__tests__/DOM.js' => 'c984504b',
@ -753,7 +753,7 @@ return array(
'javelin-view-interpreter' => 'f829edb3', 'javelin-view-interpreter' => 'f829edb3',
'javelin-view-renderer' => '6c2b09a2', 'javelin-view-renderer' => '6c2b09a2',
'javelin-view-visitor' => 'efe49472', 'javelin-view-visitor' => 'efe49472',
'javelin-websocket' => '0c4969d6', 'javelin-websocket' => '3ffe32d6',
'javelin-workboard-board' => '8935deef', 'javelin-workboard-board' => '8935deef',
'javelin-workboard-card' => 'c587b80f', 'javelin-workboard-card' => 'c587b80f',
'javelin-workboard-column' => '21df4ff5', 'javelin-workboard-column' => '21df4ff5',
@ -981,9 +981,6 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-router', 'javelin-router',
), ),
'0c4969d6' => array(
'javelin-install',
),
'0ca788bd' => array( '0ca788bd' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -1148,6 +1145,9 @@ return array(
'javelin-workflow', 'javelin-workflow',
'javelin-stratcom', 'javelin-stratcom',
), ),
'3ffe32d6' => array(
'javelin-install',
),
'408bf173' => array( '408bf173' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',

View file

@ -130,8 +130,14 @@ JX.install('WebSocket', {
_onopen: function() { _onopen: function() {
this._isOpen = true; this._isOpen = true;
// Reset the reconnect delay, since we connected successfully. // Since we connected successfully, reset the reconnect delay to 0.
this._resetDelay();
// This will make us try the first reconnect immediately after a
// connection failure. This limits downtime in cases like a service
// restart or a load balancer connection timeout.
// We only do an immediate retry after a successful connection.
this._delayUntilReconnect = 0;
var handler = this.getOpenHandler(); var handler = this.getOpenHandler();
if (handler) { if (handler) {
@ -190,7 +196,11 @@ JX.install('WebSocket', {
// Increase the reconnect delay by a factor of 2. If we fail to open the // Increase the reconnect delay by a factor of 2. If we fail to open the
// connection, the close handler will send us back here. We'll reconnect // connection, the close handler will send us back here. We'll reconnect
// more and more slowly until we eventually get a valid connection. // more and more slowly until we eventually get a valid connection.
if (!this._delayUntilReconnect) {
this._resetDelay();
} else {
this._delayUntilReconnect = this._delayUntilReconnect * 2; this._delayUntilReconnect = this._delayUntilReconnect * 2;
}
// Max out at 5 minutes between attempts. // Max out at 5 minutes between attempts.
this._delayUntilReconnect = Math.min(this._delayUntilReconnect, 300000); this._delayUntilReconnect = Math.min(this._delayUntilReconnect, 300000);