How do I spawn inactive objects on new clients?

So it appears that if an object spawned with NetworkServer.Spawn is inactive on the server when a client connects, it will never be spawned on that client even if it is reactivated. Is this intended behavior? And how can i work around it, is my only option to never disable any object on the server?

So i delved through the source code to see where exactly the distinction between inactive and active objects happens when spawning, and i found it in NetworkServer.SetClientReadyInternal, this is the part that is called only for connections that aren’t the local host:

foreach (NetworkIdentity uv in objects.Values)
{
    if (uv == null)
    {
        if (LogFilter.logWarn) { Debug.LogWarning("Invalid object found in server local object list (null NetworkIdentity)."); }
        continue;
    }
    if (!uv.gameObject.activeSelf)
    {
        continue;
    }

    if (LogFilter.logDebug) { Debug.Log("Sending spawn message for current server objects name='" + uv.gameObject.name + "' netId=" + uv.netId); }

    var vis = uv.OnCheckObserver(conn);
    if (vis)
    {
        uv.AddObserver(conn);
    }
}

Basically when you call NetworkServer.SetClientReady(conn), conn is only added as an observer to objects that have activeSelf == true, unless its the local connection. So we can just add the connection as an observer to the objects that are inactive, right after calling NetworkServer.SetClientReady.
Heres the code im using:

private void SetClientReadyIncludeInactive(NetworkConnection conn) {
    NetworkServer.SetClientReady(conn);

    //tell client to spawn inactive objects, because SetClientReady wont
    AddObserverToInactive(conn);
}

private void AddObserverToInactive(NetworkConnection conn) {
    if(conn.connectionId == 0) {
        //local host has observer added to inactive NetworkBehaviours by SetClientReady already
        return;
    }

    foreach(NetworkIdentity netId in NetworkServer.objects.Values) {
        if(netId == null) {
            Debug.LogError("Trying to add observer to object of null NetworkIdentity.", this);
            continue;
        }
        if(!netId.gameObject.activeSelf) {
            MethodInfo OnCheckObserver = typeof(NetworkIdentity).GetMethod("OnCheckObserver", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo AddObserver = typeof(NetworkIdentity).GetMethod("AddObserver", BindingFlags.NonPublic | BindingFlags.Instance);

            if((bool)OnCheckObserver.Invoke(netId, new object[] { conn })) {
                AddObserver.Invoke(netId, new object[] { conn });
            }
        }
    }
}

The only thing to worry about now is that objects will be spawned as active on the new client, but I could just use a sync var for that. Or maybe send a message to the new client with a list of all the inactive objects and then set them as inactive in the handler.

Edit: Still not sure if this is a bug or not, if not i think SetClientReady should take a bool that says whether to add the connection as an observer to inactive objects. Maybe I’ll add a pull request if this approach works out well.

We has this problem for our cached objects. They disabled when in cache.
For us help call NetworkServer.Spawn() after each reuse object.