mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 13:43:55 +00:00

This test ensures that a http client request with the default agent that has a socket that is immediately destroyed can still be caught by adding an error event listener to the request object. PR-URL: https://github.com/nodejs/node/pull/12854 Fixes: https://github.com/nodejs/node/issues/12841 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
13 lines
352 B
JavaScript
13 lines
352 B
JavaScript
'use strict';
|
|
|
|
// Make sure http.request() can catch immediate errors in
|
|
// net.createConnection().
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const req = http.get({ host: '127.0.0.1', port: 1 });
|
|
req.on('error', common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ECONNREFUSED');
|
|
}));
|