src/util.js
function addReconnectOnReadonly(cfg) {
  const noop = () => false;
  const userReconn = (typeof cfg.reconnectOnError === 'function') ? cfg.reconnectOnError : noop;
  cfg.reconnectOnError = err => {
    const shouldReconnect = (isReadonlyError(err) || userReconn(err)) ? 2 : false;
    if (shouldReconnect) console.warn(RECONNECT_WARNING);
    return shouldReconnect;
  };
}
function addReconnectOnReadonly(cfg) {
  const noop = () => false;
  const userReconn = (typeof cfg.reconnectOnError === 'function') ? cfg.reconnectOnError : noop;
  cfg.reconnectOnError = err => {
    const shouldReconnect = (isReadonlyError(err) || userReconn(err)) ? 2 : false;
    if (shouldReconnect) console.warn(RECONNECT_WARNING);
    return shouldReconnect;
  };
}
function addReconnectOnReadonly ( cfg ) { const noop = ( ) => false ; const userReconn = ( typeof cfg . reconnectOnError === 'function' ) ? cfg . reconnectOnError : noop ; cfg . reconnectOnError = err => { const shouldReconnect = ( isReadonlyError ( err ) || userReconn ( err ) ) ? 2 : false ; if ( shouldReconnect ) console . warn ( RECONNECT_WARNING ) ; return shouldReconnect ; } ; }
This is necessary for the store to handle the case when
another master is selected in ElastiCache, while
connecting to the Primary Endpoint.

@see https://github.com/dowjones/distribucache-redis-store/issues/3
@see https://github.com/luin/ioredis#reconnect-on-error
This is necessary for the store to handle the case when another master is selected in ElastiCache while connecting to the Primary Endpoint .