Error: Can't set headers after they are sent
jessebye opened this issue · 3 comments
jessebye commented
We are seeing this randomly on our npm-register
server:
logging error with Opbeat: { uuid: '9fa0244a-aa03-4cb4-aef8-9a6a992e3ad0' }
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:356:11)
at Object.set (/usr/lib/node_modules/npm-register/node_modules/koa/lib/response.js:434:16)
at Object.proto.(anonymous function) [as set] (/usr/lib/node_modules/npm-register/node_modules/delegates/index.js:40:31)
at Object.<anonymous> (/usr/lib/node_modules/npm-register/routes/packages.js:45:8)
at next (native)
at Object.next (/usr/lib/node_modules/npm-register/node_modules/koa-timeout/node_modules/co/index.js:74:21)
at Object.<anonymous> (/usr/lib/node_modules/npm-register/node_modules/koa-timeout/node_modules/co/index.js:93:18)
at Immediate.<anonymous> (/usr/lib/node_modules/npm-register/node_modules/koa-timeout/node_modules/co/index.js:52:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
Whenever this error is logged, the corresponding npm install
logs an error:
npm ERR! registry error parsing json\nnpm ERR!
(often there are several of these in a row)
After we restart npm-register, the install may succeed. But after a while, it will begin having the same issue again.
jdx commented
I haven't had time to fully investigate these but I can tell you it's happening because the request is timing out and it's trying to set the headers on the timed out request
dgautsch commented
When you say "after we install" is this after uploading a new package or installing the server? Or does it start occurring randomly after the server has been running for a while.? Can you provide more reproduction steps? Thanks!