You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you get in a state where memcached attempts to reconnect, it will call ping(this.tokens[1]), which attempts to spawn a binary to call ping -c 3. The ping function in Javascript does not handle the case where the ping binary is not present - specifically it's missing an .on(error) handler that could catch the situation where ping is not found, has the wrong permissions, or the running process does not have permission to spawn children.
function ping (host, callback) {
var isWin = process.platform.indexOf('win') === 0; // win32 or win64
var arg = isWin ? '-n' : '-c';
var pong = spawn('ping', [arg, '3', host]); // only ping 3 times
pong.stdout.on('data', function stdoutdata (data) {
callback(false, data.toString().split('\n')[0].substr(14));
pong.kill();
});
pong.stderr.on('data', function stderrdata (data) {
callback(new Error(data.toString().split('\n')[0].substr(14)), false);
pong.kill();
});
}
The lack of a .on('error') handler means that any failure here is uncatchable and crashes the process.
More broadly I have to wonder about the effectiveness of calling ping if a connection fails - it's not clear that one TCP packet is going to have any more luck than another if the connection is in trouble.
The text was updated successfully, but these errors were encountered:
If you get in a state where memcached attempts to reconnect, it will call
ping(this.tokens[1])
, which attempts to spawn a binary to callping -c 3
. Theping
function in Javascript does not handle the case where theping
binary is not present - specifically it's missing an.on(error)
handler that could catch the situation whereping
is not found, has the wrong permissions, or the running process does not have permission to spawn children.The lack of a
.on('error')
handler means that any failure here is uncatchable and crashes the process.More broadly I have to wonder about the effectiveness of calling
ping
if a connection fails - it's not clear that one TCP packet is going to have any more luck than another if the connection is in trouble.The text was updated successfully, but these errors were encountered: