I was working with some scriptable tasks in vRO around hosts and ran into an issue calling the script. It would fail when hosts were disconnected. This brings up a good point that you should use good programming practices including checking for valid input (or null) in everything you do. In this case I can filter my select into only hosts that are connected like this:
for each (host in hosts)
if (host.runtime.connectionState.value == “connected”)
Hope it saves you some time troubleshooting.