Skip to content
Browse files

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 <>
Reviewed-By: Benjamin Gruenbaum <>
Reviewed-By: James M Snell <>
Reviewed-By: Ben Noordhuis <>
  • Loading branch information...
evanlucas authored and jasnell committed May 11, 2017
1 parent 4fabcfc commit 6cfb876d5466d58a20c629b50819eff251a27255
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/parallel/test-http-client-immediate-error.js
@@ -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: '', port: 1 });
req.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'ECONNREFUSED');

0 comments on commit 6cfb876

Please sign in to comment.
You can’t perform that action at this time.