Can I raycast gameobjects created same frame?

I am instantiating a prefab and set up its transform properties.
Right after I create it, I would like to find it using RayCast but it seems unstable.
SOmetiems raycast finds the collider, sometimes does not.
Much later, when an other script is executing as a resutl of button click, it ALWAYS hits this gameobject, so maybe the problem I am raycasting teh same frame teh object si created? I tried using coroutines and wait till end of frame but it did not work either huh. What coudl be teh rpoblem?