Error: Can't set headers after they are sent

Posted fengch

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error: Can't set headers after they are sent相关的知识,希望对你有一定的参考价值。

Error: Can‘t set headers after they are sent.
at validateHeader (_http_outgoing.js:494:11)
at ServerResponse.setHeader (_http_outgoing.js:501:3)
at ServerResponse.header (f:\VSCode\node\node06\myapp-login\node_modules\express\lib\response.js:767:10)
at ServerResponse.json (f:\VSCode\node\node06\myapp-login\node_modules\express\lib\response.js:264:10)
at ServerResponse.send (f:\VSCode\node\node06\myapp-login\node_modules\express\lib\response.js:158:21)
at movie.find.toArray (f:\VSCode\node\node06\myapp-login\routes\main.js:29:14) at result (f:\VSCode\node\node06\myapp-login\node_modules\mongodb\lib\utils.js:414:17)
at executeCallback (f:\VSCode\node\node06\myapp-login\node_modules\mongodb\lib\utils.js:406:9)
at handleCallback (f:\VSCode\node\node06\myapp-login\node_modules\mongodb\lib\utils.js:128:55)
at self.close (f:\VSCode\node\node06\myapp-login\node_modules\mongodb\lib\cursor.js:957:60)

 

发送后不能设置标头,一般是后台出了问题,(查看异步线程的程序,是否应该改为主线程优先执行一下)

 var promise = new Promise((resolve,rejected)function{

  异步函数

})

以上是关于Error: Can't set headers after they are sent的主要内容,如果未能解决你的问题,请参考以下文章

SNORT中无法启动DAQ。提示ERROR: Can't set DAQ BPF filter to '–T' (hO)!

express 遇到问题 - Error: Can't set headers after they are sent

解决Error: Can't find Python executable "python", you can set the PYTHON env variable(示例

解决Error: Can't find Python executable "python", you can set the PYTHON env variable

Error: Can't find Python executable "python", you can set the PYTHON env variable.解决办法

解决ERROR 1231 (42000): Variable ‘time_zone‘ can‘t