This can happen on the home page, especially if you create your context object with a DS nanoflow. The AppEvents widget is a little eager and will call your onload event even if the context is not loaded yet into the dataview.
I use an enum for that, with values created and initialized and add an attribute on the context object with that enum. The DS nanoflow or native navigation nanoflow creates the object with enum value created. On the page, show AppEvents widget only if the enum is anything but empty. In the AppEvents onload nanoflow I set the state to initialized. I use this pattern all the time, to do initialization before actually showing the home page content. You can wrap the other content in a container with condition for visible set to the initialized value.
This way, the AppEvents widget will call your nanoflow with a valid context object and you can show other content after your initialization has finished, like getting local storage content or triggering a synchronization