From 7f1b116a63f946819fa7a890f022a802168ef7da Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Mon, 11 Aug 2025 16:49:50 +0700 Subject: [PATCH] fix(lib/utils/callback): only use `enqueueJob` if engine queue is used --- lib/utils/src/callback.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/utils/src/callback.ts b/lib/utils/src/callback.ts index 7975c8d..e553dd4 100644 --- a/lib/utils/src/callback.ts +++ b/lib/utils/src/callback.ts @@ -22,7 +22,10 @@ const now = (cb: () => any) => { */ export const asap = (cb: (...args: any[]) => any) => { // @ts-expect-error - ;(HermesInternal.enqueueJob ?? setImmediate ?? now)(cb) + ;(HermesInternal.useEngineQueue() + ? // @ts-expect-error + HermesInternal.enqueueJob + : (globalThis.setImmediate ?? globalThis.setTimeout ?? now))(cb, 0) } export const noop = () => {}