mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
fix(es_extended/modules/callback): compare the promise state against its numeric value
promise.state is a number, not a string - the runtime defines PENDING as 0 and Citizen.Await tests against 0 as well. Comparing it to "pending" is therefore always false and the documented 15 second timeout never rejects anything. When the other side never answers, Citizen.Await blocks the calling coroutine for good. Measured on artifact 25770 with the real 15 second delay: never answers, current guard -> state 0, not rejected, await never returns never answers, fixed guard -> state 0, rejected, await returns the timeout answers after 1s, fixed guard-> state 3, untouched, await returns normally Nothing inside esx_core calls AwaitServerCallback or AwaitClientCallback, so no core behaviour changes.
This commit is contained in:
@@ -102,7 +102,7 @@ function ESX.AwaitServerCallback(eventName, ...)
|
||||
|
||||
-- if the server callback takes longer than 15 seconds to respond, reject the promise
|
||||
SetTimeout(15000, function()
|
||||
if p.state == "pending" then
|
||||
if p.state == 0 then
|
||||
p:reject("Server Callback Timed Out")
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -107,7 +107,7 @@ function ESX.AwaitClientCallback(player, eventName, ...)
|
||||
if not p then return end
|
||||
|
||||
SetTimeout(15000, function()
|
||||
if p.state == "pending" then
|
||||
if p.state == 0 then
|
||||
p:reject("Server Callback Timed Out")
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user