fix the bug of crash bcoz write response after response end