From 54bd75e9a6c5bb3084bc83b5fe05b3b7c57f533f Mon Sep 17 00:00:00 2001 From: beaudan Date: Mon, 13 May 2019 06:17:13 +1000 Subject: [PATCH] Wait for a longer time after failed poll and extend default timeout --- js/modules/loki_rpc.js | 2 +- libtextsecure/http-resources.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/modules/loki_rpc.js b/js/modules/loki_rpc.js index 03f971bc0..19e54b71a 100644 --- a/js/modules/loki_rpc.js +++ b/js/modules/loki_rpc.js @@ -8,7 +8,7 @@ const endpointBase = '/v1/storage_rpc'; // A small wrapper around node-fetch which deserializes response const fetch = async (url, options = {}) => { - const timeout = options.timeout || 5000; + const timeout = options.timeout || 10000; const method = options.method || 'GET'; const address = parse(url).hostname; diff --git a/libtextsecure/http-resources.js b/libtextsecure/http-resources.js index 02f1eb95b..88200968c 100644 --- a/libtextsecure/http-resources.js +++ b/libtextsecure/http-resources.js @@ -3,7 +3,8 @@ // eslint-disable-next-line func-names (function() { let server; - const POLL_TIME = 100; + const SUCCESS_POLL_TIME = 100; + const FAIL_POLL_TIME = 2000; function stringToArrayBufferBase64(string) { return dcodeIO.ByteBuffer.wrap(string, 'base64').toArrayBuffer(); @@ -89,10 +90,11 @@ } catch (err) { connected = false; } + const pollTime = connected ? SUCCESS_POLL_TIME : FAIL_POLL_TIME; callback(connected); setTimeout(() => { this.pollServer(callback); - }, POLL_TIME); + }, pollTime); }; this.isConnected = function isConnected() {