# TPromise Destructor Error After Closing Editor

**URL:** <https://forums.unrealengine.com/t/tpromise-destructor-error-after-closing-editor/1788994>\
**Category:** C++\
**Tags:** multithreading, unreal-engine, question, CPP\
**Created:** [April 5, 2024, 8:42am UTC](https://forums.unrealengine.com/t/tpromise-destructor-error-after-closing-editor/1788994 "2024-04-05T08:42:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eray\_ozr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eray\_ozr](https://forums.unrealengine.com/u/eray_ozr)\
**Post date:** [April 5, 2024, 8:42am UTC](https://forums.unrealengine.com/t/tpromise-destructor-error-after-closing-editor/1788994/1 "2024-04-05T08:42:36Z")

</div>

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
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.

```auto
/** 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 ?

---

<div class="post-metadata">

**Author:** ![eray\_ozr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eray\_ozr](https://forums.unrealengine.com/u/eray_ozr)\
**Post date:** [April 5, 2024, 10:19am UTC](https://forums.unrealengine.com/t/tpromise-destructor-error-after-closing-editor/1788994/2 "2024-04-05T10:19:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 5, 2024, 10:19am UTC](https://forums.unrealengine.com/t/tpromise-destructor-error-after-closing-editor/1788994/3 "2024-05-05T10:19:51Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
