diff --git a/lib/_http_client.js b/lib/_http_client.js index e8285fe81012c7..3ba986cf6fcfb0 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -68,9 +68,9 @@ function ClientRequest(options, cb) { } // Explicitly pass through this statement as agent will not be used // when createConnection is provided. - } else if (!(agent instanceof Agent.Agent)) { + } else if (typeof agent.addRequest !== 'function') { throw new TypeError( - 'Agent option must be an instance of http.Agent, undefined or false.' + 'Agent option must be an Agent-like object, undefined, or false.' ); } self.agent = agent; diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js index 559166ec421ea2..e89bcfad5b5995 100644 --- a/test/parallel/test-http-client-reject-unexpected-agent.js +++ b/test/parallel/test-http-client-reject-unexpected-agent.js @@ -49,7 +49,7 @@ server.listen(0, baseOptions.host, common.mustCall(function() { failingAgentOptions.forEach((agent) => { assert.throws( () => createRequest(agent), - /^TypeError: Agent option must be an instance of http.Agent/, + /^TypeError: Agent option must be an Agent-like object/, `Expected typeof agent: ${typeof agent} to be rejected` ); });