Skip to content

Commit fbd970e

Browse files
committed
test: add failing "error" event catching test
Right now the ECONNREFUSED error is an uncaught exception :(
1 parent fed5cf1 commit fbd970e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ describe('HttpsProxyAgent', function () {
173173
});
174174
});
175175
});
176+
it('should emit an "error" event on the `http.ClientRequest` if the proxy does not exist', function (done) {
177+
// port 4 is a reserved, but "unassigned" port
178+
var proxyUri = 'http://127.0.0.1:4';
179+
var agent = new HttpsProxyAgent(proxyUri);
180+
181+
var opts = url.parse('http://nodejs.org');
182+
opts.agent = agent;
183+
184+
var req = http.get(opts);
185+
req.once('error', function (err) {
186+
assert.equal('ECONNREFUSED', err.code);
187+
req.abort();
188+
done();
189+
});
190+
});
176191
});
177192

178193
});

0 commit comments

Comments
 (0)