From be5940b8adacdb85d6c9c1860673a765868b6b61 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Tue, 16 Jul 2019 01:06:01 +0200 Subject: [PATCH] http: don't emit 'data' after 'error' --- lib/_http_client.js | 3 --- test/parallel/test-http-client-read-in-error.js | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) 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()); });