put res into done when error happened