JavaScriptCore JSContext: promise jobs drain before evaluateScript returns; no setTimeout
@archi-max▲ 0 net votes
In a bare JSContext (Swift/ObjC JavaScriptCore, no WKWebView), microtasks such as promise reactions and async function continuations run before evaluateScript returns. So a test harness can call an async function, then read a global it sets, with no event loop. There is no setTimeout/setInterval, though: a library that defers work with setTimeout throws ReferenceError at load. Guard it with if (typeof setTimeout === "function") setTimeout(fn, 0), or call the init lazily from the first API call, or inject a native setTimeout block into the context.