Verse: defer not always working

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Summary

Code in ‘defer’ blocks sometimes doesn’t get called. I’m seeing it specifically in async functions that are cancelled by a race block. There are some cases where you can cancel an aync function with a race, and the defer block does get called. In this repro example, the function is in a race with an Await() on an event that the function signals itself, and in this case the defer doesn’t happen.

Steps to Reproduce

1: Create a new device and paste this code inside the class definition:

TestEvent : event() = event(){}

OnBegin<override>()<suspends>:void=
    Sleep(1.0)
    Print("Starting race")
    race:
        Func1()
        TestEvent.Await()
    Print("Finished race")

Func1()<suspends>:void=
    Print("Enter Func1")
    defer:
        Print("Exit Func1")
    Sleep(1.0)
    TestEvent.Signal()
    Sleep(Inf)

2: create an instance of this device in the map and run
3: observe the output

Expected Result

I would expect the following output:
LogVerse: : Starting race
LogVerse: : Enter Func1
LogVerse: : Exit Func1
LogVerse: : Finished race

Observed Result

I get the following output:
LogVerse: : Starting race
LogVerse: : Enter Func1
LogVerse: : Finished race

Platform(s)

Windows PC

The status of FORT-788902 incident has been moved from ‘Needs Triage’ to ‘To Do’.

I can confirm on that, defer isn’t executed when function is exited early in race. Please fix

I’m having issues with defer not working in suspends functions that are ended early from being in a race.

can you link to this card so we can follow it?

hello guys it’s been a year can you fix it already

This is a year old :frowning: This is a basic verse function. What’s going on with Epic and fixing stuff.

Ask yourself this simple question…

Why are creators fed-up and leaving to go to other platforms.

This post clearly shows some reason.

I keep saying this but this Backlogged/DoLater response on any bug shouldn’t be a thing. This will be used as an excuse internally i imagine.

I managed a team of over 78 people in a high manufacturing environment with fast turn arounds and this method of thinking wouldn’t happen. If something had an issue it would be sorted asap. Obviously priorities should be set but if any bug was in a list and not completed within 1 month then something is wrong in the system and it needs to be checked. The main reason would be not enough staff or current staff are stretched too thin and cannot keep up.

What is happening is bugs are not getting fixed and they keep adding up in a list until you get what we have now a system that is so buggy its crazy. Its held together with glue and tape and this is no way to allow the system to be for creators.

I don’t get the issue just simple cut this 40% share to 35% hire more staff and office space to fix bugs.

Imagine using an office vehicle to deliver parcels and the wipers have a fault sometimes they work sometimes they don’t the company wouldn’t say oh its backlogged its something we would like to address in the future. This fault would be fixed!!!

I feel something needs to happen and i cant accept Epic don’t know this.

Its all good and well saving money but it’ll hurt more when there are no creators left to earn you money because they all left for Roblox or GTA 6 ect

Anyways just wanted to share this as when i see these posts a year old and its not fixed its not acceptable imo.