Commit 855e3f74b58 for nodejs
commit 855e3f74b5868bd9a560e95dd82d70da92e307e3
Author: Efe Karasakal <hi@efe.dev>
Date: Thu Oct 8 15:36:20 2026 +0200
doc: clarify http Agent keepSocketAlive behavior
Signed-off-by: Efe Karasakal <hi@efe.dev>
PR-URL: https://github.com/nodejs/node/pull/66252
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
diff --git a/doc/api/http.md b/doc/api/http.md
index 7800e3119bb..6f6adecacf4 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -286,15 +286,14 @@ added: v8.1.0
-->
* `socket` {stream.Duplex}
+* Returns: {boolean}
Called when `socket` is detached from a request and could be persisted by the
-`Agent`. Default behavior is to:
+`Agent`. The `Agent` calls this method only when `keepAlive` is enabled.
-```js
-socket.setKeepAlive(true, this.keepAliveMsecs);
-socket.unref();
-return true;
-```
+By default, TCP keep-alive is enabled and the socket is unrefed. A server
+keep-alive timeout hint may adjust the socket timeout or cause this method to
+return `false`; otherwise, it returns `true`.
This method can be overridden by a particular `Agent` subclass. If this
method returns a falsy value, the socket will be destroyed instead of persisting