Error: Attempt to process /Script/MyModule/ before it has been added

Hey, i have a runtime module that implements a K2Node and some logic. It works in the editor and standalone game. But as soon as i try to call functions from my c++ code, i get a crash and the following error:
Fatal error: [File: Engine\Source\Runtime\CoreUObject\Private\Serialization\AsyncLoading.cpp] [Line: 734] Attempt to process /Script/MyModule/ before it has been added.
I tried different loading phases, but that didn’t solve my problem. Does anyone has an idea what is causing this?

I reproduced this issue by initializing a static variable with references to object classes.

EX :
TSet<UClass*> MyClass::MyStaticClassSet { AMyWorldActor::StaticClass() };

When I moved this logic to my constructor, the error went away.

If its not a phase loading issue, you’re most likely statically referring to do something which needs to be loaded. Move your logic into something like the constructor or the PostLoad function of your objects.

In case anyone is still experiencing this error, I could actually solve it by changing the Loading Phase of my Editor Module to PostEngineInit.

Hope that helps someone.

I thought K2Node was only implementable in editor only modules? is it possible to include K2Node in a game module? I don’t know th at that would be useful… hmm.