Skip to content

Commit 6cfb876

Browse files
evanlucasjasnell
authored andcommitted
test: add regression test for immediate socket errors
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: #12854 Fixes: #12841 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 4fabcfc commit 6cfb876

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
// Make sure http.request() can catch immediate errors in
4+
// net.createConnection().
5+
6+
const common = require('../common');
7+
const assert = require('assert');
8+
const http = require('http');
9+
const req = http.get({ host: '127.0.0.1', port: 1 });
10+
req.on('error', common.mustCall((err) => {
11+
assert.strictEqual(err.code, 'ECONNREFUSED');
12+
}));

0 commit comments

Comments
 (0)