From c6766bbe77d0f0023541104c841eb54306f1d1fb Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Mon, 28 Jan 2019 14:55:56 -0800 Subject: [PATCH] Fix timeout issue for real this time --- plugin/src/ApiContext.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugin/src/ApiContext.lua b/plugin/src/ApiContext.lua index 540a978e..898564c6 100644 --- a/plugin/src/ApiContext.lua +++ b/plugin/src/ApiContext.lua @@ -140,14 +140,18 @@ end function ApiContext:retrieveMessages() local url = ("%s/api/subscribe/%s"):format(self.baseUrl, self.messageCursor) - return Http.get(url) - :catch(function(err) - if err.type == HttpError.Error.Timeout then - return Http.get(url) - end + local function sendRequest() + return Http.get(url) + :catch(function(err) + if err.type == HttpError.Error.Timeout then + return sendRequest() + end - return Promise.reject(err) - end) + return Promise.reject(err) + end) + end + + return sendRequest() :andThen(rejectFailedRequests) :andThen(function(response) local body = response:json()