Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setkeepalive < 1000 silently ignored #57712

Open
rotu opened this issue Apr 1, 2025 · 0 comments
Open

setkeepalive < 1000 silently ignored #57712

rotu opened this issue Apr 1, 2025 · 0 comments

Comments

@rotu
Copy link

rotu commented Apr 1, 2025

Version

22.14.0

Platform

N/A

Subsystem

No response

What steps will reproduce the bug?

Create a TCP socket and call socket.setKeepAlive(true, 400).

How often does it reproduce? Is there a required condition?

Any keepalive less than 1 second.

What is the expected behavior? Why is that the expected behavior?

This should send keepalive packets every 400 ms.

The documentation says as much:

keepAliveInitialDelay {number} If set to a positive number, it sets the
initial delay before the first keepalive probe is sent on an idle socket.
Default: 0.

What do you see instead?

The code truncates to the nearest 1000ms, so the socket doesn't send keepalive packets and no error is issued.

Additional information

It seems this parameter is even broken in the tests.

connection.setKeepAlive(true, common.platformTimeout(50));

const s = clientConnection.setKeepAlive(true, 400);

Ideally, the keepalive interval would be respected in milliseconds. Assuming that's infeasible,

  1. a runtime warning should be issued if setKeepAlive is given a value <1000.
  2. the documentation should be updated to reflect that, even though the value is given in milliseconds, it will only be respected to the second.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant