TPromise Destructor Error After Closing Editor

Hi, I have a question about TPromise.

I am working on LibHv based HTTP server implementation to UE5.

  • I have a an UCLASS and it has a TPromise<int> Promise;
  • I set it’s value with a function which is inside a member function like this this->Promise.SetValue(200);
  • After that I initialize my UCLASS in this callback in FRunnableThread
auto Callback_Router_Handler = [this](HttpRequest* Request, HttpResponse* Response)->int
        {
            UHttpConnectionLhv* LibHvConnection = NewObject<UHttpConnectionLhv>();
            LibHvConnection->Request = Request;
            LibHvConnection->Response = Response;
            this->Parent_Actor->DelegateHttpLibHv.Broadcast(LibHvConnection);
            
            TSharedFuture<int> Future = LibHvConnection->Promise.GetFuture().Share();
            Future.Wait();
        
            int ResponseCode = Future.Get();

            return ResponseCode;
        };

the problem is, I can get correct respond code and there is no crash at game play but when I want to close UE5 editor, it shows me this error.

/** Destructor. */
    ~TPromiseBase()
    {
        if (State.IsValid())
        {
            // if you hit this assertion then your promise never had its result
            // value set. broken promises are considered programming errors.
            check(State->IsComplete());
        }
    }

Is there any suggestion about it ?

Okay, solved the problem !

  • I added a TSharedFuture member variable to UCLASS
  • I created a local TPromise variable and set its value inside a local function.
  • I set TSharedFuture with TPromise’s future.
  • I called TSharedFuture from from runnable thread.