From 2bb0d68415d6cb891ddacbdf07f0140b0a6cc136 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Wed, 19 Oct 2022 20:20:38 +1100 Subject: [PATCH] fix(callback): bad argument to unpack when callback throws error Throwing an error responds with false rather than a string. --- imports/callback/client.lua | 2 +- imports/callback/server.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/imports/callback/client.lua b/imports/callback/client.lua index 188e0ed9a..e47a3ccc3 100644 --- a/imports/callback/client.lua +++ b/imports/callback/client.lua @@ -50,7 +50,7 @@ local function triggerServerCallback(_, event, delay, cb, ...) return promise:resolve(response and { msgpack.unpack(response) } or {}) end - return cb and cb(msgpack.unpack(response)) + return cb and cb(response and msgpack.unpack(response)) end if promise then diff --git a/imports/callback/server.lua b/imports/callback/server.lua index dfc559ab2..184dd31dd 100644 --- a/imports/callback/server.lua +++ b/imports/callback/server.lua @@ -31,7 +31,7 @@ local function triggerClientCallback(_, event, playerId, cb, ...) return promise:resolve(response and { msgpack.unpack(response) } or {}) end - return cb and cb(msgpack.unpack(response)) + return cb and cb(response and msgpack.unpack(response)) end if promise then @@ -74,4 +74,6 @@ function lib.callback.register(name, cb) end) end -return lib.callback \ No newline at end of file +return lib.callback + +