Socket
Socket
Sign inDemoInstall

agent-base

Package Overview
Dependencies
0
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

13

agent.js

@@ -60,5 +60,15 @@

// create the `net.Socket` instance
var sync = true;
this.callback(req, opts, function (err, socket) {
function emitErr () {
req.emit('error', err);
}
if (err) {
req.emit('error', err);
if (sync) {
// need to defer the "error" event, when sync, because by now the `req`
// instance hasn't event been passed back to the user yet...
process.nextTick(emitErr);
} else {
emitErr();
}
} else {

@@ -68,2 +78,3 @@ req.onSocket(socket);

});
sync = false;
};

@@ -0,1 +1,6 @@

1.0.1 / 2013-09-09
==================
- Fix passing an "error" object to the callback function on the first tick
1.0.0 / 2013-09-09

@@ -2,0 +7,0 @@ ==================

2

package.json
{
"name": "agent-base",
"version": "1.0.0",
"version": "1.0.1",
"description": "Turn a function into an `http.Agent` instance",

@@ -5,0 +5,0 @@ "main": "agent.js",

@@ -15,2 +15,33 @@

describe('Agent', function () {
describe('"error" event', function () {
it('should be invoked on `http.ClientRequest` instance if passed to callback function on the first tick', function (done) {
var agent = new Agent(function (req, opts, fn) {
fn(new Error('is this caught?'));
});
var info = url.parse('http://127.0.0.1/foo');
info.agent = agent;
var req = http.get(info);
req.on('error', function (err) {
assert.equal('is this caught?', err.message);
done();
});
});
it('should be invoked on `http.ClientRequest` instance if passed to callback function after the first tick', function (done) {
var agent = new Agent(function (req, opts, fn) {
process.nextTick(function () {
fn(new Error('is this caught?'));
});
});
var info = url.parse('http://127.0.0.1/foo');
info.agent = agent;
var req = http.get(info);
req.on('error', function (err) {
assert.equal('is this caught?', err.message);
done();
});
});
});
});
describe('"http" module', function () {

@@ -83,3 +114,2 @@ var server;

});
});

@@ -86,0 +116,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc