Skip to content
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: 7 additions & 2 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,11 +1027,16 @@ function resOnFinish(req, res, socket, state, server) {
socket.end();
}
} else if (state.outgoing.length === 0) {
if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') {
const keepAliveTimeout = NumberIsFinite(server.keepAliveTimeout) && server.keepAliveTimeout >= 0 ?
server.keepAliveTimeout : 0;
const keepAliveTimeoutBuffer = NumberIsFinite(server.keepAliveTimeoutBuffer) && server.keepAliveTimeoutBuffer >= 0 ?
server.keepAliveTimeoutBuffer : 1e3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move the 1e3 into a shared const and use it at all places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't want to break. It was 1e3 pre keepAliveTimeoutBuffer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your comment. Why is using a shard constant instead of duplicating the literal breaking?


if (keepAliveTimeout && typeof socket.setTimeout === 'function') {
// Extend the internal timeout by the configured buffer to reduce
// the likelihood of ECONNRESET errors.
// This allows fine-tuning beyond the advertised keepAliveTimeout.
socket.setTimeout(server.keepAliveTimeout + server.keepAliveTimeoutBuffer);
socket.setTimeout(keepAliveTimeout + keepAliveTimeoutBuffer);
state.keepAliveTimeoutSet = true;
}
} else {
Expand Down
Loading