From e55c5c341dd3f00d2a9a679adecbb6f71e1768f0 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 18 Jan 2019 09:08:09 -0500 Subject: [PATCH] http: reuse noop function in socketOnError() PR-URL: https://github.com/nodejs/node/pull/25566 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- lib/_http_server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index c0172ccf52d1d9..799a1c55932b8b 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -499,13 +499,14 @@ function onParserExecute(server, socket, parser, state, ret) { onParserExecuteCommon(server, socket, parser, state, ret, undefined); } +const noop = () => {}; const badRequestResponse = Buffer.from( `HTTP/1.1 400 ${STATUS_CODES[400]}${CRLF}${CRLF}`, 'ascii' ); function socketOnError(e) { // Ignore further errors this.removeListener('error', socketOnError); - this.on('error', () => {}); + this.on('error', noop); if (!this.server.emit('clientError', e, this)) { if (this.writable) {