node.js - node+express 在chrome打开调试模式时会报错?
某草草
某草草 2017-07-06 10:35:27
0
1
918
_http_outgoing.js:504
    throw new Error('Can\'t set headers after they are sent.');
    ^

Error: Can't set headers after they are sent.
    at validateHeader (_http_outgoing.js:504:11)
    at ServerResponse.setHeader (_http_outgoing.js:511:3)
    at Array.write (D:\GitSpace\fbms\node_modules\_finalhandler@1.0.3@finalhandl
er\index.js:254:9)
    at listener (D:\GitSpace\fbms\node_modules\_on-finished@2.3.0@on-finished\in
dex.js:169:15)
    at onFinish (D:\GitSpace\fbms\node_modules\_on-finished@2.3.0@on-finished\in
dex.js:100:5)
    at callback (D:\GitSpace\fbms\node_modules\_ee-first@1.1.1@ee-first\index.js
:55:10)
    at IncomingMessage.onevent (D:\GitSpace\fbms\node_modules\_ee-first@1.1.1@ee
-first\index.js:93:5)
    at emitNone (events.js:105:13)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1045:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9)
Program node app.js exited with code 1


如果不启动调试模式就不会有这个报错,页面加载和req,res都正常

某草草
某草草

全部回复(1)
学霸

代码写的有问题,跟调试模式无关,response响应已经被发送了,但是你却仍然想修改已经被发送的响应头。
一旦调用 response.end() 方法,代表此响应已经结束并发送,在此之后不得调用诸如 response.writeHead() 等修改 response 的方法。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板