Skip to content

Commit

Permalink
fix: remove dependency on net-keepalive
Browse files Browse the repository at this point in the history
node's net socket.setKeepAlive has an optional initial delay parameter. By setting this, it will request that the socket sends a TCP keep-alive probe every N milliseconds, removing the need for net-keepalive which is not portable.

https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
  • Loading branch information
Matthew Fisher committed Apr 9, 2021
1 parent a3e1501 commit a3e6c0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 87 deletions.
88 changes: 5 additions & 83 deletions package-lock.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
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"isomorphic-ws": "^4.0.1",
"js-yaml": "^3.13.1",
"jsonpath-plus": "^0.19.0",
"net-keepalive": "2.0.4",
"openid-client": "^4.1.1",
"request": "^2.88.0",
"rfc4648": "^1.3.0",
Expand Down
4 changes: 1 addition & 3 deletions src/watch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import byline = require('byline');
import keepalive = require('net-keepalive');
import request = require('request');
import { Duplex } from 'stream';
import { KubeConfig } from './config';
Expand Down Expand Up @@ -115,8 +114,7 @@ export class Watch {
req.on('error', doneCallOnce);
req.on('socket', (socket) => {
socket.setTimeout(30000);
socket.setKeepAlive(true);
keepalive.setKeepAliveInterval(socket, 30000);
socket.setKeepAlive(true, 30000);
});
stream.on('error', doneCallOnce);
stream.on('close', () => doneCallOnce(null));
Expand Down

0 comments on commit a3e6c0a

Please sign in to comment.