Preventing race condition during network connect