Skip to content

Commit

Permalink
test: add regression test for immediate socket errors
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
evanlucas authored and jasnell committed May 23, 2017
1 parent fb44461 commit ecc31dd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/parallel/test-http-client-immediate-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'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');
}));

0 comments on commit ecc31dd

Please sign in to comment.