diff --git a/lib/_http_server.js b/lib/_http_server.js index dd06c9cfe3f9c0..f8aacb40452c8a 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -499,6 +499,7 @@ 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}` + `Connection: close${CRLF}${CRLF}`, 'ascii' @@ -506,7 +507,7 @@ const badRequestResponse = Buffer.from( 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) {