This should also check the case err == nil in case this bug 5781 is fixed someday