mirror of https://github.com/nodejs/node.git
http: remove default 'error' listener on upgrade
Remove the default `'error'` listener when the socket is freed. This is consistent with the client and prevents spurious `'clientError'` events from being emitted on the server. PR-URL: https://github.com/nodejs/node/pull/18868 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>pull/18881/merge
parent
d6fc7e3af4
commit
51be03cd57
|
@ -521,6 +521,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) {
|
|||
socket.removeListener('close', state.onClose);
|
||||
socket.removeListener('drain', state.onDrain);
|
||||
socket.removeListener('drain', ondrain);
|
||||
socket.removeListener('error', socketOnError);
|
||||
unconsume(parser, socket);
|
||||
parser.finish();
|
||||
freeParser(parser, req, null);
|
||||
|
|
|
@ -30,6 +30,13 @@ server.on('connect', common.mustCall((req, socket, firstBodyChunk) => {
|
|||
assert.strictEqual(req.method, 'CONNECT');
|
||||
assert.strictEqual(req.url, 'google.com:443');
|
||||
|
||||
// Make sure this socket has detached.
|
||||
assert.strictEqual(socket.listeners('close').length, 0);
|
||||
assert.strictEqual(socket.listeners('drain').length, 0);
|
||||
assert.strictEqual(socket.listeners('data').length, 0);
|
||||
assert.strictEqual(socket.listeners('end').length, 1);
|
||||
assert.strictEqual(socket.listeners('error').length, 0);
|
||||
|
||||
socket.write('HTTP/1.1 200 Connection established\r\n\r\n');
|
||||
|
||||
let data = firstBodyChunk.toString();
|
||||
|
|
Loading…
Reference in New Issue