victorquinn/memcache-plus

Spaces in the key cause errors on a set call

Closed this issue · 1 comments

Please add this check to
function validateKey(key, operation) {
misc.assert(key, 'Cannot "' + operation + '" without key!');
misc.assert(typeof key === 'string', 'Key needs to be of type "string"');
misc.assert(key.length < 250, 'Key must be less than 250 characters long');
}

Memcached does not allow spaces in the key...
https://stackoverflow.com/questions/5826768/can-memcached-keys-contain-spaces

Just got same issue.
I'm leaving a stacktrace here in case someone will search for error message. Took me some time to figure the error out.

/home/vitalii/projects/mem-test/node_modules/memcache-plus/lib/connection.js:246
    if (deferred.type === 'autodiscovery') {
                 ^

TypeError: Cannot read property 'type' of undefined
    at Connection.read (/home/vitalii/projects/mem-test/node_modules/memcache-plus/lib/connection.js:246:18)
    at Carrier.emit (events.js:198:13)
    at /home/vitalii/projects/mem-test/node_modules/carrier/lib/carrier.js:24:12
    at process._tickCallback (internal/process/next_tick.js:61:11)

A possible workaround: https://stackoverflow.com/a/37355569