diff --git a/lib/https.js b/lib/https.js index c44766bd6e6571..1ca546ac106248 100644 --- a/lib/https.js +++ b/lib/https.js @@ -119,6 +119,9 @@ function createConnection(port, host, options) { function Agent(options) { + if (!(this instanceof Agent)) + return new Agent(options); + http.Agent.call(this, options); this.defaultPort = 443; this.protocol = 'https:'; diff --git a/test/parallel/test-https-agent-constructor.js b/test/parallel/test-https-agent-constructor.js new file mode 100644 index 00000000000000..942ad07b4a3870 --- /dev/null +++ b/test/parallel/test-https-agent-constructor.js @@ -0,0 +1,7 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const https = require('https'); + +assert.doesNotThrow(() => { https.Agent(); }); +assert.ok(https.Agent() instanceof https.Agent);