Skip to content

Commit

Permalink
http: add comments in _http_incoming
Browse files Browse the repository at this point in the history
PR-URL: #33035
Refs: #30625
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
dnlup authored and nodejs-github-bot committed Dec 17, 2020
1 parent 70eaf55 commit 5ae9690
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/_http_incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ IncomingMessage.prototype._destroy = function _destroy(err, cb) {

// If aborted and the underlying socket not already destroyed,
// destroy it.
// We have to check if the socket is already destroyed because finished
// does not call the callback when this methdod is invoked from `_http_client`
// in `test/parallel/test-http-client-spurious-aborted.js`
if (this.socket && !this.socket.destroyed && this.aborted) {
this.socket.destroy(err);
const cleanup = finished(this.socket, (e) => {
Expand Down Expand Up @@ -359,6 +362,9 @@ IncomingMessage.prototype._dump = function _dump() {
};

function onError(instance, cb, error) {
// This is to keep backward compatible behavior.
// An error is emitted only if there are listeners attached to
// the event.
if (instance.listenerCount('error') > 0) {
cb(error);
} else {
Expand Down

0 comments on commit 5ae9690

Please sign in to comment.