You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Use a small timeout when trying to poll when having previously failed. This makes re-connects propagate more quickly.
This commit is contained in:
@@ -2150,16 +2150,23 @@ function _pollForEvents(client, attempt) {
|
|||||||
if (!client.clientRunning) {
|
if (!client.clientRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var timeoutMs = client._config.pollTimeout;
|
||||||
|
if (attempt > 1) {
|
||||||
|
// we think the connection is dead. If it comes back up, we won't know
|
||||||
|
// about it till /events returns. If the timeout= is high, this could
|
||||||
|
// be a long time. Set it to 1 when doing retries.
|
||||||
|
timeoutMs = 1;
|
||||||
|
}
|
||||||
var discardResult = false;
|
var discardResult = false;
|
||||||
var timeoutObj = setTimeout(function() {
|
var timeoutObj = setTimeout(function() {
|
||||||
discardResult = true;
|
discardResult = true;
|
||||||
console.error("/events request timed out.");
|
console.error("/events request timed out.");
|
||||||
_pollForEvents(client);
|
_pollForEvents(client);
|
||||||
}, client._config.pollTimeout + (20 * 1000)); // 20s buffer
|
}, timeoutMs + (20 * 1000)); // 20s buffer
|
||||||
|
|
||||||
client._http.authedRequest(undefined, "GET", "/events", {
|
client._http.authedRequest(undefined, "GET", "/events", {
|
||||||
from: client.store.getSyncToken(),
|
from: client.store.getSyncToken(),
|
||||||
timeout: client._config.pollTimeout
|
timeout: timeoutMs
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
if (discardResult) {
|
if (discardResult) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user