Problem with NetworkServer.Destroy

I’m using Unity 5.2, and I’m seeing something odd with NetworkServer.Destroy. Specifically, it’s not destroying the object. I turned on the Debug log level, and I can see that the server thinks it’s destroying the object in question, but it’s not actually being destroyed.

The object in question has become the parent of other objects with NetworkIdentity, so I suspect that may be part of the problem. On the server, before calling NetworkServer.Destroy on the root object I’ve tried detaching the child objects and destroying them, but that doesn’t help either.

I’ve even tried defining a new message with the id of the object to destroy, and sending it to the clients via NetworkServer.SendToAll, and having the clients call GameObject.Destroy on the object in question, and that doesn’t work either. GameObject.DestroyImmediate does seem to work, but the fact that I have to go to such extremes makes me think I’m missing something fundamental.

Turns out we had something being spawned which started a coroutine, then waited for NaN seconds from the coroutine, which seemed to completely break coroutines & deferred methods (i.e. Invoke). It seems that Destroy implicitly defers, so it wasn’t working, whereas DestroyImmediate runs immediately.