mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
node:timers fixes (#16855)
This commit is contained in:
@@ -16,15 +16,14 @@
|
||||
namespace Bun {
|
||||
using namespace JSC;
|
||||
|
||||
extern "C" void Bun__JSTimeout__call(JSC::EncodedJSValue encodedTimeoutValue, JSC::JSGlobalObject* globalObject)
|
||||
template<typename T>
|
||||
void callInternal(T* timeout, JSGlobalObject* globalObject)
|
||||
{
|
||||
static_assert(std::is_same_v<T, WebCore::JSTimeout> || std::is_same_v<T, WebCore::JSImmediate>,
|
||||
"wrong type passed to callInternal");
|
||||
|
||||
auto& vm = JSC::getVM(globalObject);
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
if (UNLIKELY(vm.hasPendingTerminationException())) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebCore::JSTimeout* timeout = jsCast<WebCore::JSTimeout*>(JSC::JSValue::decode(encodedTimeoutValue));
|
||||
|
||||
JSCell* callbackCell = timeout->m_callback.get().asCell();
|
||||
JSValue restoreAsyncContext {};
|
||||
@@ -80,4 +79,21 @@ extern "C" void Bun__JSTimeout__call(JSC::EncodedJSValue encodedTimeoutValue, JS
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void Bun__JSTimeout__call(JSC::EncodedJSValue encodedTimeoutValue, JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
if (UNLIKELY(vm.hasPendingTerminationException())) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSValue timeoutValue = JSValue::decode(encodedTimeoutValue);
|
||||
if (auto* timeout = jsDynamicCast<WebCore::JSTimeout*>(timeoutValue)) {
|
||||
return callInternal(timeout, globalObject);
|
||||
} else if (auto* immediate = jsDynamicCast<WebCore::JSImmediate*>(timeoutValue)) {
|
||||
return callInternal(immediate, globalObject);
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED_WITH_MESSAGE("Object passed to Bun__JSTimeout__call is not a JSTimeout or a JSImmediate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user