Skip to content

Commit

Permalink
Drop the keep-alive package in favor of node's setKeepAlive defaults
Browse files Browse the repository at this point in the history
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
  • Loading branch information
thgreasi committed Apr 9, 2024
1 parent c6827ee commit be682c7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 152 deletions.
13 changes: 0 additions & 13 deletions lib/utils/device/api.ts
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/
import * as _ from 'lodash';
import type { NodeJSSocketWithFileDescriptor } from 'net-keepalive';
import * as os from 'os';
import * as request from 'request';
import type * as Stream from 'stream';

Expand Down Expand Up @@ -214,17 +212,6 @@ export class DeviceAPI {
}
try {
res.socket.setKeepAlive(true, 1000);
if (os.platform() !== 'win32') {
const NetKeepalive = await import('net-keepalive');
// Certain versions of typescript won't convert
// this automatically
const sock = res.socket as any as NodeJSSocketWithFileDescriptor;
// We send a tcp keepalive probe once every 5 seconds
NetKeepalive.setKeepAliveInterval(sock, 5000);
// After 5 failed probes, the connection is marked as
// closed
NetKeepalive.setKeepAliveProbes(sock, 5);
}
} catch (error) {
reject(error);
}
Expand Down
138 changes: 0 additions & 138 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -254,7 +254,6 @@
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"ndjson": "^2.0.0",
"net-keepalive": "^3.0.0",
"node-cleanup": "^2.1.2",
"node-unzip-2": "^0.2.8",
"open": "^7.1.0",
Expand Down

0 comments on commit be682c7

Please sign in to comment.