server: cleanup logs and do not break if err.Code == 504