From 317abb8131c6b45d301fa47f5c43377b38713ff8 Mon Sep 17 00:00:00 2001 From: Haram Jeong <91401364+haramj@users.noreply.github.com> Date: Fri, 18 Sep 2026 14:37:40 +0900 Subject: [PATCH] doc: clarify sub-1000ms behavior in socket.setKeepAlive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current documentation states that `initialDelay` and `interval` are divided by 1000 and rounded down, but does not explicitly mention that values less than 1000ms will result in 0 seconds. This can lead to confusion when users pass values like 400ms expecting sub-second keepalive delays. Add a concrete example showing that 400ms rounds down to 0 seconds. Refs: https://github.com/nodejs/node/issues/57712 Signed-off-by: haramjeong <04harams77@gmail.com> PR-URL: https://github.com/nodejs/node/pull/65869 Reviewed-By: James M Snell Reviewed-By: Ulises Gascón --- doc/api/net.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/net.md b/doc/api/net.md index b96c46e542d..0767deeeceb 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -1632,7 +1632,9 @@ corresponding system default unchanged. `initialDelay` and `interval` are specified in milliseconds but the underlying socket options are configured in whole seconds; the values are -divided by `1000` and rounded down before being applied. +divided by `1000` and rounded down before being applied. For example, +setting `initialDelay` to `400` will result in a `TCP_KEEPIDLE` of `0` +seconds (since `400 / 1000` rounds down to `0`). Enabling the keep-alive functionality will set the following socket options: