Skip to content

Commit

Permalink
net: replace destroySoon with socket.end()
Browse files Browse the repository at this point in the history
As per @ronag suggestion, destroySoon is considered
obsolete, all of its functionnality having been
implemented by Writeable.end()

Refs: #36205
  • Loading branch information
mmomtchev committed Nov 21, 2020
1 parent dd2e3ed commit e6699c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,7 @@ function responseOnEnd() {

if (!req.shouldKeepAlive) {
if (socket.writable) {
debug('AGENT socket.destroySoon()');
if (typeof socket.destroySoon === 'function')
socket.destroySoon();
else
socket.end();
socket.end();
}
assert(!socket.writable);
} else if (req.finished && !this.aborted) {
Expand Down
6 changes: 1 addition & 5 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,7 @@ function resOnFinish(req, res, socket, state, server) {
process.nextTick(emitCloseNT, res);

if (res._last) {
if (typeof socket.destroySoon === 'function') {
socket.destroySoon();
} else {
socket.end();
}
socket.end();
} else if (state.outgoing.length === 0) {
if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') {
socket.setTimeout(server.keepAliveTimeout);
Expand Down

0 comments on commit e6699c6

Please sign in to comment.