fix server crash with the log as below:
"can't render headers after they are sent to the client"