UEFN island instantly crashes Fortnite to Desktop using defer expression

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Summary

I’ve been recently converting a lot of the code in my codebase to take advantage of concurrency in Verse, but I’ve seem to encountered a bug while using defer that causes the entire game to crash to desktop whilst outputting no errors at all in the UEFN editor.

I’m not entirely sure the reason behind this and while I’m hesitant to share the actual code snippets as this is work related, I’ll try to summarize as best I can on how my code is set up.

spawn {Function1}

Function1()
	race:
		BrokenFunction()
		function2()
		ExitEvent.Await()
	
BrokenFunction()
	var SubscribedEvents:cancelable = array{}
	
	for (PropMover:PropMovers):
		Event:= PropMover.PropHitEvent.Subscribe(OnPropHit())
		set SubscribedEvents += array{Event}
	
	defer:
		for(Event:SubscribedEvents)
			Event.Cancel()
	
	Sleep(Inf)

I’m pretty sure this is not the correct way to handle this sort of thing but it was intended to be a “quick” way to ensure that events are unsubscribed after the race expression completes. However this inadvertently caused a bug that does not highlight any errors in VSCode, no errors in UEFN after building verse code and allows the session to launch with no errors. Despite this, when connecting to the session from a Fortnite Client, the game throws you into the tiny waiting room with the trees then after about 5-10 seconds kicks you to desktop.

Steps to Reproduce

spawn {Function1}

Function1()
	race:
		BrokenFunction()
		function2()
		ExitEvent.Await()
	
BrokenFunction()
	var SubscribedEvents:cancelable = array{}
	
	for (Item:Items):
		Event:= PropMover.PropHitEvent.Subscribe(OnPropHit())
		set SubscribedEvents += array{Event}
	
	defer:
		for(Event:SubscribedEvents)
			Event.Cancel()
	
	Sleep(Inf)

Expected Result

After race expression completes, the defer expression runs and unsubscribes from all events.

Observed Result

Everything builds and launches successfully but the Fortnite Client crashes to desktop upon joining

Platform(s)

PC