From 27c445e196ef185a61ddceed4298b25c32ed09e0 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Tue, 7 Jul 2026 21:50:36 +0700 Subject: [PATCH] fix(lib/modules/native): await callable method properly --- lib/modules/src/native/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/modules/src/native/index.ts b/lib/modules/src/native/index.ts index a09ac1a..62b4180 100644 --- a/lib/modules/src/native/index.ts +++ b/lib/modules/src/native/index.ts @@ -133,7 +133,12 @@ function _wrapJSMethod(method: AnyFunction) { return (...args: any[]) => { try { const ret = method(...args) - _returnJSCall({ result: ret ?? null }) + if (ret instanceof Promise) + ret.then( + result => _returnJSCall({ result: result ?? null }), + error => _returnJSCall({ error: getErrorStack(error) }), + ) + else _returnJSCall({ result: ret ?? null }) } catch (error) { _returnJSCall({ error: getErrorStack(error) }) }