@@ -772,13 +772,15 @@ void JSPromise::resolveWithoutPromise(JSGlobalObject* globalObject, JSValue reso
772772
773773void JSPromise::rejectWithoutPromise (JSGlobalObject* globalObject, JSValue argument, JSValue onFulfilled, JSValue onRejected, JSValue context)
774774{
775+ VM& vm = globalObject->vm ();
776+ auto scope = DECLARE_THROW_SCOPE (vm);
777+
775778 UNUSED_PARAM (onFulfilled);
776779#if USE(BUN_JSC_ADDITIONS)
777780 // AsyncLocalStorage support: wrap context with async context if present
778781 if (auto * asyncContextData = globalObject->m_asyncContextData .get ()) {
779782 JSValue asyncContext = asyncContextData->getInternalField (0 );
780783 if (!asyncContext.isUndefined ()) {
781- VM& vm = globalObject->vm ();
782784 // Create array [context, asyncContext]
783785 ObjectInitializationScope initializationScope (vm);
784786 JSArray* contextArray = JSArray::tryCreateUninitializedRestricted (initializationScope,
@@ -791,18 +793,21 @@ void JSPromise::rejectWithoutPromise(JSGlobalObject* globalObject, JSValue argum
791793 }
792794 }
793795#endif
796+ scope.release ();
794797 globalObject->queueMicrotask (InternalMicrotask::PromiseReactionJobWithoutPromise, onRejected, argument, context, jsUndefined ());
795798}
796799
797800void JSPromise::fulfillWithoutPromise (JSGlobalObject* globalObject, JSValue argument, JSValue onFulfilled, JSValue onRejected, JSValue context)
798801{
802+ VM& vm = globalObject->vm ();
803+ auto scope = DECLARE_THROW_SCOPE (vm);
804+
799805 UNUSED_PARAM (onRejected);
800806#if USE(BUN_JSC_ADDITIONS)
801807 // AsyncLocalStorage support: wrap context with async context if present
802808 if (auto * asyncContextData = globalObject->m_asyncContextData .get ()) {
803809 JSValue asyncContext = asyncContextData->getInternalField (0 );
804810 if (!asyncContext.isUndefined ()) {
805- VM& vm = globalObject->vm ();
806811 // Create array [context, asyncContext]
807812 ObjectInitializationScope initializationScope (vm);
808813 JSArray* contextArray = JSArray::tryCreateUninitializedRestricted (initializationScope,
@@ -815,6 +820,7 @@ void JSPromise::fulfillWithoutPromise(JSGlobalObject* globalObject, JSValue argu
815820 }
816821 }
817822#endif
823+ scope.release ();
818824 globalObject->queueMicrotask (InternalMicrotask::PromiseReactionJobWithoutPromise, onFulfilled, argument, context, jsUndefined ());
819825}
820826
0 commit comments