From 5571c0ddebe72e894e41bbee56c7165a55788288 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 8db7018cc98aba..24ebd41bb504c4 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -503,13 +503,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) {