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) {