		auto Phase2Async(Scheduler::AsyncWait& wait) -> bool final {
			// Same as regular `Phase2()` but if it returns a promise we will wait on it
			if (!(return_transfer_options == TransferOptions{TransferOptions::Type::Reference})) {
				throw RuntimeTypeError("`result` options are not available for `applySyncPromise`");
			}
			Local<Context> context_handle = Deref(context);
			Context::Scope context_scope{context_handle};
			Local<Value> fn = Deref(reference);
			if (!fn->IsFunction()) {
				throw RuntimeTypeError("Reference is not a function");
			}
			Local<Value> recv_inner = recv->TransferIn();
			std::vector<Local<Value>> argv_inner = TransferArguments();
			Local<Value> value = RunWithTimeout(
				timeout,
				[&fn, &context_handle, &recv_inner, &argv_inner]() {
					return fn.As<Function>()->Call(context_handle, recv_inner, argv_inner.size(), argv_inner.empty() ? nullptr : &argv_inner[0]);
				}
			);
			if (value->IsPromise()) {
				Isolate* isolate = Isolate::GetCurrent();
				// This is only called from the default isolate, so we don't need an IsolateSpecific
				static Persistent<Function> callback_persistent{isolate, CompileAsyncWrapper()};
				Local<Function> callback_fn = Deref(callback_persistent);
				did_finish = std::make_shared<bool>(false);
				std::array<Local<Value>, 3> argv;
				argv[0] = External::New(isolate, reinterpret_cast<void*>(this));
				argv[1] = External::New(isolate, reinterpret_cast<void*>(new shared_ptr<bool>(did_finish)));
				argv[2] = value;
				async_wait = &wait;
				Unmaybe(callback_fn->Call(context_handle, callback_fn, 3, &argv.front()));
				return true;
			} else {
				ret = TransferOut(value, return_transfer_options);
				return false;
			}
		}
		auto Phase2Async(Scheduler::AsyncWait& wait) -> bool final {
			 
			if (!(return_transfer_options == TransferOptions{TransferOptions::Type::Reference})) {
				throw RuntimeTypeError("`result` options are not available for `applySyncPromise`");
			}
			Local<Context> context_handle = Deref(context);
			Context::Scope context_scope{context_handle};
			Local<Value> fn = Deref(reference);
			if (!fn->IsFunction()) {
				throw RuntimeTypeError("Reference is not a function");
			}
			Local<Value> recv_inner = recv->TransferIn();
			std::vector<Local<Value>> argv_inner = TransferArguments();
			Local<Value> value = RunWithTimeout(
				timeout,
				[&fn, &context_handle, &recv_inner, &argv_inner]() {
					return fn.As<Function>()->Call(context_handle, recv_inner, argv_inner.size(), argv_inner.empty() ? nullptr : &argv_inner[0]);
				}
			);
			if (value->IsPromise()) {
				Isolate* isolate = Isolate::GetCurrent();
				 
				static Persistent<Function> callback_persistent{isolate, CompileAsyncWrapper()};
				Local<Function> callback_fn = Deref(callback_persistent);
				did_finish = std::make_shared<bool>(false);
				std::array<Local<Value>, 3> argv;
				argv[0] = External::New(isolate, reinterpret_cast<void*>(this));
				argv[1] = External::New(isolate, reinterpret_cast<void*>(new shared_ptr<bool>(did_finish)));
				argv[2] = value;
				async_wait = &wait;
				Unmaybe(callback_fn->Call(context_handle, callback_fn, 3, &argv.front()));
				return true;
			} else {
				ret = TransferOut(value, return_transfer_options);
				return false;
			}
		}