fix(lib/modules/native): await callable method properly

This commit is contained in:
PalmDevs 2026-07-07 21:50:36 +07:00
parent 420f3e803e
commit 27c445e196
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -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) })
}