jdx / npm-register

Your own private npm registry and backup server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Can't set headers after they are sent

jessebye opened this issue · comments

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.

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

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!

@dgautsch the server was running for a month or two before we started seeing this. Can't reproduce now after updating to the latest version of npm-register, so it might have been specific to the older version we had been using.