[CRITICAL] Defer does not execute after cancellation through race

Summary

Here’s the repro

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

test_device := class(creative_device):

    StartFail()<suspends>:void=
        Print("StartFail")
        defer:
            Print("StartFail Ended (from suspending scope)") # Never prints
        
        race:
            Sleep(Inf)
            Sleep(Inf)

        Sleep(Inf)

    StartSucceed()<suspends>:void=
        Print("StartSucceed")
        defer:
            Print("StartSucceed Ended (from suspending scope)") # Prints correctly
        
        # race:
        #     Sleep(Inf)
        #     Sleep(Inf)

        Sleep(Inf)

    OnBegin<override>()<suspends>:void=
        race:
            Sleep(1.0)
            StartFail()
            StartSucceed() # Not required to repro

Prints

[2024.10.20-13.59.20:863][673]LogVerse: : StartFail
[2024.10.20-13.59.20:864][673]LogVerse: : StartSucceed
[2024.10.20-13.59.21:854][790]LogVerse: : StartSucceed Ended (from suspending scope)

(As you can see the StartFail defer never fires, this is an issue when trying to build complex async structures)

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

See summary

Expected Result

See summary

Observed Result

See summary

Platform(s)

PC

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

1 Like

Can confirm it.

1 Like