diff --git a/lib/_http_client.js b/lib/_http_client.js index 956dd8da7ab00f..d6e194963dd854 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -399,9 +399,6 @@ function socketErrorListener(err) { req.emit('error', err); } - // Handle any pending data - socket.read(); - const parser = socket.parser; if (parser) { parser.finish(); diff --git a/test/parallel/test-http-client-read-in-error.js b/test/parallel/test-http-client-read-in-error.js index 73b86b0d7edd62..5e38e49c1f6fde 100644 --- a/test/parallel/test-http-client-read-in-error.js +++ b/test/parallel/test-http-client-read-in-error.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const net = require('net'); const http = require('http'); @@ -37,4 +37,5 @@ http.request({ agent }).once('error', function() { console.log('ignore'); + this.on('data', common.mustNotCall()); });