Assertion Failed !IsGarbageCollecting()

I have a plugin that tries to create UObjects after a database request, but occasionally it crashes because its trying to make UResultRow (a UObject) while its garbage collecting? I’ve break pointed it and VS says I’m in the game thread when its trying to create the UObject. How do I wait for garbage collection?

So this was happening when an actor was destroyed that executed a query. It would start a nobabandonable task, then the actor that started it would be destroyed. So on return the actor would be being garbage collected hence it blew up. The fix for me was to put in a IsDestroyed bool and just drop the query results instead of trying to populate new uobjects in a destroying actor