Skip to content

Commit

Permalink
http: remove default 'drain' listener on upgrade
Browse files Browse the repository at this point in the history
Ensure that the default `'drain'` listener is removed before the
`'connect'` or `'upgrade'` event is emitted.
  • Loading branch information
lpinca committed Feb 19, 2018
1 parent 28f3ffb commit 575da74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const { OutgoingMessage } = require('_http_outgoing');
const Agent = require('_http_agent');
const { Buffer } = require('buffer');
const { urlToOptions, searchParamsSymbol } = require('internal/url');
const { outHeadersKey } = require('internal/http');
const { outHeadersKey, ondrain } = require('internal/http');
const { nextTick } = require('internal/process/next_tick');
const errors = require('internal/errors');

Expand Down Expand Up @@ -424,6 +424,7 @@ function socketOnData(d) {

socket.removeListener('data', socketOnData);
socket.removeListener('end', socketOnEnd);
socket.removeListener('drain', ondrain);
parser.finish();
freeParser(parser, req, socket);

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-http-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ server.listen(0, common.mustCall(() => {
assert(!socket.onend);
assert.strictEqual(socket.listeners('connect').length, 0);
assert.strictEqual(socket.listeners('data').length, 0);
assert.strictEqual(socket.listeners('drain').length, 0);

// the stream.Duplex onend listener
// allow 0 here, so that i can run the same test on streams1 impl
Expand Down

0 comments on commit 575da74

Please sign in to comment.