mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Improve Rojo sync reliability (#739)
Uses non-recursive main loop and avoids hanging promises
This commit is contained in:
parent
dd01a9bef3
commit
8662d2227c
2 changed files with 35 additions and 29 deletions
|
|
@ -11,13 +11,6 @@ local validateApiInfo = Types.ifEnabled(Types.ApiInfoResponse)
|
|||
local validateApiRead = Types.ifEnabled(Types.ApiReadResponse)
|
||||
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)
|
||||
if response.code >= 400 then
|
||||
local message = string.format("HTTP %s:\n%s", tostring(response.code), response.body)
|
||||
|
|
@ -212,12 +205,8 @@ function ApiContext:retrieveMessages()
|
|||
local function sendRequest()
|
||||
local request = Http.get(url)
|
||||
:catch(function(err)
|
||||
if err.type == Http.Error.Kind.Timeout then
|
||||
if self.__connected then
|
||||
return sendRequest()
|
||||
else
|
||||
return hangingPromise()
|
||||
end
|
||||
if err.type == Http.Error.Kind.Timeout and self.__connected then
|
||||
return sendRequest()
|
||||
end
|
||||
|
||||
return Promise.reject(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue