diff --git a/lib/https.js b/lib/https.js index 4ecd2e8db63412..ef0c8dd04638b8 100644 --- a/lib/https.js +++ b/lib/https.js @@ -97,6 +97,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);