diff --git a/lib/https/index.js b/lib/https/index.js index fb80603f9..f2998ae74 100644 --- a/lib/https/index.js +++ b/lib/https/index.js @@ -679,6 +679,7 @@ function toHttp1(req, res) { var handleAbort = function() { if (client) { client.abort(); + req.stream && req.stream.close(); client = null; } }; @@ -721,6 +722,7 @@ function toHttp1(req, res) { client = http.request(options); client.on('error', handleError); client.on('response', function(svrRes) { + svrRes.on('error', handleError); try { var code = svrRes.statusCode; res.writeHead(code, getStatusMessage(svrRes), formatRawHeaders(svrRes, isH2)); diff --git a/lib/init.js b/lib/init.js index 5052cac3e..4bdd55471 100644 --- a/lib/init.js +++ b/lib/init.js @@ -28,6 +28,8 @@ function addErrorEvents(req, res) { if (clientReq) { if (clientReq.abort) { clientReq.abort(); + } else if (req.useH2 && clientReq.close) { + clientReq.close(); } else if (clientReq.destroy) { clientReq.destroy(); }