1. 程式人生 > >Error: Can't set headers after they are sent

Error: Can't set headers after they are sent

after r.js div oar mod function body can exec

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