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:
Selt
2026-07-27 03:24:53 +02:00
parent ca597cf6f4
commit eaf0db6c5e
2 changed files with 2 additions and 2 deletions
@@ -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)