Skip to content

doc: clarify sub-1000ms behavior in socket.setKeepAlive - #65869

Open
haramj wants to merge 1 commit into
nodejs:mainfrom
haramj:doc-setkeepalive-sub1000
Open

doc: clarify sub-1000ms behavior in socket.setKeepAlive#65869
haramj wants to merge 1 commit into
nodejs:mainfrom
haramj:doc-setkeepalive-sub1000

Conversation

@haramj

@haramj haramj commented Sep 7, 2026

Copy link
Copy Markdown
Member

Description

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.

This PR adds a concrete example showing that 400ms rounds down to 0 seconds.

Example

socket.setKeepAlive(true, 400);
// TCP_KEEPIDLE becomes 0 seconds (400 / 1000 rounds down to 0)

Refs

Checklist

  • Documentation is changed or added
  • Commit message follows commit guidelines

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: nodejs#57712

Signed-off-by: haramjeong <04harams77@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. net Issues and PRs related to the net subsystem. labels Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to Node.js documentation. net Issues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants