summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-agent-close.js
blob: 84ed5e57c5fb86d6719c6d6c1e0f2c00a7785dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');

const agent = new http.Agent();
const _err = new Error('kaboom');
agent.createSocket = function(req, options, cb) {
  cb(_err);
};

const req = http
  .request({
    agent
  })
  .on('error', common.mustCall((err) => {
    assert.strictEqual(err, _err);
  }))
  .on('close', common.mustCall(() => {
    assert.strictEqual(req.destroyed, true);
  }));