3rd-Eden/node-memcached — Issue #17: private.singles() always has an error Parameter
Author: renzhong
Created: 2011-11-01 07:55:15+00:00
State: open

I try to use function stats() in memcached like this:
memcached.version(function(err,data){
if(err){
console.error(err);
}
console.log( JSON.stringify ( data ));
});

the output always like this:
[]
[{"server":"127.0.0.1:11211","pid":2508,"uptime":1922,"time":1320131967,"version":"1.4.9","libevent":"2.0.15-stable","pointer_size":64,"rusage_user":"0.030000","rusage_system":"0.080000","curr_connections":11,"total_connections":34,"connection_structures":12,"reserved_fds":20,"cmd_get":24,"cmd_set":21,"cmd_flush":0,"cmd_touch":0,"get_hits":23,"get_misses":1,"delete_misses":0,"delete_hits":1,"incr_misses":0,"incr_hits":2,"decr_misses":0,"decr_hits":0,"cas_misses":0,"cas_hits":0,"cas_badval":0,"touch_hits":0,"touch_misses":0,"auth_cmds":0,"auth_errors":0,"bytes_read":1529,"bytes_written":10502,"limit_maxbytes":67108864,"accepting_conns":1,"listen_disabled_num":0,"threads":4,"conn_yields":0,"hash_power_level":16,"hash_bytes":524288,"hash_is_expanding":0,"expired_unfetched":0,"evicted_unfetched":0,"bytes":144,"curr_items":2,"total_items":17,"evictions":0,"reclaimed":0}]

the first null [] must be console by cnosole.error(err). I try version() again ,the result is same as before.
I read some source code and find the private.singles() maybe has a little bug.
private.singles = function singles(type, callback){
var memcached = this
, responses = []
, errors = []
, calls

// handle multiple servers
, handle = function(err, results){
if (err) errors.push(err);
if (results) responses = responses.concat(results);

// multi calls should ALWAYS return an array!
if (!--calls) callback(errors, responses);
};
since errors be defined to [],it can be test by callback,I'm an Chinese C++ coder and can't ensure this is right,so expected your replay.