mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Fix request timeout in long polling causing error to bubble to console
This commit is contained in:
parent
2493c70241
commit
af866f0665
1 changed files with 13 additions and 2 deletions
|
|
@ -9,6 +9,13 @@ local validateApiInfo = Types.ifEnabled(Types.ApiInfoResponse)
|
||||||
local validateApiRead = Types.ifEnabled(Types.ApiReadResponse)
|
local validateApiRead = Types.ifEnabled(Types.ApiReadResponse)
|
||||||
local validateApiSubscribe = Types.ifEnabled(Types.ApiSubscribeResponse)
|
local validateApiSubscribe = Types.ifEnabled(Types.ApiSubscribeResponse)
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Returns a promise that will never resolve nor reject.
|
||||||
|
]]
|
||||||
|
local function hangingPromise()
|
||||||
|
return Promise.new(function() end)
|
||||||
|
end
|
||||||
|
|
||||||
local function rejectFailedRequests(response)
|
local function rejectFailedRequests(response)
|
||||||
if response.code >= 400 then
|
if response.code >= 400 then
|
||||||
-- TODO: Nicer error types for responses, using response JSON if valid.
|
-- TODO: Nicer error types for responses, using response JSON if valid.
|
||||||
|
|
@ -139,8 +146,12 @@ function ApiContext:retrieveMessages()
|
||||||
local function sendRequest()
|
local function sendRequest()
|
||||||
return Http.get(url)
|
return Http.get(url)
|
||||||
:catch(function(err)
|
:catch(function(err)
|
||||||
if err.type == Http.Error.Kind.Timeout and self.__connected then
|
if err.type == Http.Error.Kind.Timeout then
|
||||||
|
if self.__connected then
|
||||||
return sendRequest()
|
return sendRequest()
|
||||||
|
else
|
||||||
|
return hangingPromise()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue