summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-req-error-dont-double-fire.js
blob: 996540fc96c72e56b34a1628991562afb9904d87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';
const assert = require('assert');
const http = require('http');
const common = require('../common');

// Invalid hostname as per https://tools.ietf.org/html/rfc2606#section-2
const host = 'this.hostname.is.invalid';
const req = http.get({ host });
const err = new Error('mock unexpected code error');
req.on('error', common.mustCall(() => {
  throw err;
}));

process.on('uncaughtException', common.mustCall((e) => {
  assert.strictEqual(e, err);
}));