memcache
memcache copied to clipboard
Check for undefined peekCommand queue entry
Fixes #26
Problem
In some cases, bad commands (e.g. invalid keys) sent in parallel at a high throughput to a memcache server will result in the error described in #26.
Since this code path runs in an event listener after client initialization and not as a result of a function called in user land, this results in a crashed Node.js process (aka uncaught exception).
Solution
Check retrieve for truthiness before attempting to push a value on it or set .error on it.
This doesn't solve the underlying root/concurrency problem per-se, but it makes the method more resilient to upstream failure.