diff --git a/test/parallel/test-http-client-immediate-error.js b/test/parallel/test-http-client-immediate-error.js new file mode 100644 index 00000000000000..9fbe052efd4104 --- /dev/null +++ b/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: '127.0.0.1', port: 1 }); +req.on('error', common.mustCall((err) => { + assert.strictEqual(err.code, 'ECONNREFUSED'); +}));