Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Intermittently getting empty responses from GET /package/version requests #241

Open
jkroso opened this issue Aug 9, 2015 · 0 comments
Open

Comments

@jkroso
Copy link

jkroso commented Aug 9, 2015

The function that makes the requests is this one:

function latest(name, spec,done){
  var path = encodeURI('/' + name + '/' + spec)
  http.get({
    hostname: 'registry.npmjs.org',
    path: path
  }, function (res) {
    var buf = ''
    res.on('data', function(data){
      buf += data
    })
    res.on('end', function(){
      if (buf) done(null, JSON.parse(buf))
      else done(new Error('received an empty response for ' + path))
    })
    res.on('error', done)
  })
}

Most of the time its fine but it gets called hundreds of times and usually one request will have this problem. If I rerun the program immediately it typically will have the same problem on a request for the same module it had problems with last time. If I wait a minute or so It will come right but then usually another module becomes the problem. I have been able to reproduce with curl but often it works with curl and not node. Yet npm view always works. This used to be pretty reliable. Has the HTTP API changed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant