Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-registry-client

Package Overview
Dependencies
Maintainers
4
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-registry-client - npm Package Compare versions

Comparing version 7.1.2 to 7.2.0

test/fetch-streaming.js

46

lib/request.js

@@ -95,4 +95,13 @@ module.exports = regRequest

function makeRequest (uri, params, cb_) {
var cb = once(cb_)
var socket
var cb = once(function (er, parsed, raw, response) {
if (socket) {
// The socket might be returned to a pool for re-use, so don’t keep
// the 'error' listener from here attached.
socket.removeListener('error', cb)
}
return cb_(er, parsed, raw, response)
})
var parsed = url.parse(uri)

@@ -150,9 +159,40 @@ var headers = {}

var done = requestDone.call(this, params.method, uri, cb)
var req = request(opts, decodeResponseBody(done))
var req = request(opts, params.streaming ? undefined : decodeResponseBody(done))
req.on('error', cb)
// This should not be necessary, as the HTTP implementation in Node
// passes errors occurring on the socket to the request itself. Being overly
// cautious comes at a low cost, though.
req.on('socket', function (s) {
s.on('error', cb)
socket = s
socket.on('error', cb)
})
if (params.streaming) {
req.on('response', function (response) {
if (response.statusCode >= 400) {
var parts = []
response.on('data', function (data) {
parts.push(data)
})
response.on('end', function () {
decodeResponseBody(done)(null, response, Buffer.concat(parts))
})
} else {
response.on('end', function () {
// don't ever re-use connections that had server errors.
// those sockets connect to the Bad Place!
if (response.socket && response.statusCode > 500) {
response.socket.destroy()
}
})
return cb(null, response)
}
})
}
if (params.body && (params.body instanceof Stream)) {

@@ -159,0 +199,0 @@ params.body.pipe(req)

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Client for the npm registry",
"version": "7.1.2",
"version": "7.2.0",
"repository": {

@@ -8,0 +8,0 @@ "url": "https://github.com/npm/npm-registry-client.git"

@@ -262,2 +262,4 @@ # npm-registry-client

* `follow` {Boolean} Follow 302/301 responses. Optional (default: true).
* `streaming` {Boolean} Stream the request body as it comes, handling error
responses in a non-streaming way.
* `auth` {Credentials} Optional.

@@ -264,0 +266,0 @@ * `cb` {Function}

@@ -13,2 +13,10 @@ var server = require('./server.js')

// See https://github.com/npm/npm-registry-client/pull/142 for background.
// Note: `process.on('warning')` only works with Node >= 6.
process.on('warning', function (warning) {
if (/Possible EventEmitter memory leak detected/.test(warning.message)) {
throw new Error('There should not be any EventEmitter memory leaks')
}
})
module.exports = {

@@ -15,0 +23,0 @@ port: server.port,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc