Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Prevent FIN_WAIT connections by using stream.destorySoon() #524

Merged
merged 2 commits into from
Jul 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,14 @@ Client.prototype.close = function(callback, reason) {
// needed in case of errors
if (!that._closed) {
cleanup();
that.connection.stream.end();
// prefer destroy[Soon]() to prevent FIN_WAIT zombie connections
if (that.connection.stream.destroySoon) {
that.connection.stream.destroySoon();
} else if (that.connection.stream.destroy) {
that.connection.stream.destroy();
} else {
that.connection.stream.end();
}
}
});
};
Expand Down