From 467e7f51ac99df4e9284b1713d0ce2fdf57b10c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20S=C3=B6nmez?= <60190086+GenerousImpersio@users.noreply.github.com> Date: Fri, 26 May 2023 02:04:30 +0300 Subject: [PATCH] fix(package/callback): await callback response (#340) --- package/client/resource/callback/index.ts | 4 ++-- package/server/resource/callback/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package/client/resource/callback/index.ts b/package/client/resource/callback/index.ts index 9b18b429..c1697f07 100644 --- a/package/client/resource/callback/index.ts +++ b/package/client/resource/callback/index.ts @@ -42,11 +42,11 @@ export function triggerServerCallback( } export function onServerCallback(eventName: string, cb: (...args) => any) { - onNet(`__ox_cb_${eventName}`, (resource: string, key: string, ...args) => { + onNet(`__ox_cb_${eventName}`, async (resource: string, key: string, ...args) => { let response: any; try { - response = cb(...args); + response = await cb(...args); } catch (e: any) { console.error(`an error occurred while handling callback event ${eventName}`); console.log(`^3${e.stack}^0`); diff --git a/package/server/resource/callback/index.ts b/package/server/resource/callback/index.ts index d1e9a6c2..321bd7ad 100644 --- a/package/server/resource/callback/index.ts +++ b/package/server/resource/callback/index.ts @@ -26,12 +26,12 @@ export function triggerClientCallback( } export function onClientCallback(eventName: string, cb: (playerId: number, ...args) => any) { - onNet(`__ox_cb_${eventName}`, (resource: string, key: string, ...args) => { + onNet(`__ox_cb_${eventName}`, async (resource: string, key: string, ...args) => { const src = source; let response: any; try { - response = cb(src, ...args); + response = await cb(src, ...args); } catch (e: any) { console.error(`an error occurred while handling callback event ${eventName}`); console.log(`^3${e.stack}^0`);