Skip to content

Commit f11a648

Browse files
dnluptargos
authored andcommitted
http: add comments in _http_incoming
PR-URL: #33035 Refs: #30625 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 4b81d79 commit f11a648

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/_http_incoming.js

+6
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ IncomingMessage.prototype._destroy = function _destroy(err, cb) {
171171

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

361364
function onError(instance, cb, error) {
365+
// This is to keep backward compatible behavior.
366+
// An error is emitted only if there are listeners attached to
367+
// the event.
362368
if (instance.listenerCount('error') > 0) {
363369
cb(error);
364370
} else {

0 commit comments

Comments
 (0)