https://github.com/luin/ioredis/blob/master/lib/redis/event_handler.js#L76
the default error handler is just noop
If enableOfflineQueue is false, should we just throw error when connect failed?
Events could be caught by listening to the specified events of Redis instances. Say you can catch connect errors by listening to error and close. it's just a matter of convenience to return a promise of the connect method for developers to catch connect errors easier.
connect always throws when the connection is failed regardless of the value of enableOfflineQueue:
var redis = new Redis({
host: 'non-exists host',
lazyConnect: true,
enableOfflineQueue: false
});
redis.connect().catch(function () {
console.log('should throw');
});
:smile: yeah, got it.
Oh my sweet Jesus! I finally got this working...it would not work with all those fancy attributes inside of new Redis(). Kept it simple and it's finally doing what daddy wants!
console.time('Redis')
var Redis = require('ioredis'),
redis = new Redis()
redis.on('error', err => {
console.log('REDIS: FAILED')
process.exit(0)
})
redis.on('connect', () => {
app.set('redis', redis)
// continue program logic
console.timeEnd('Redis')
})
Most helpful comment
connectalways throws when the connection is failed regardless of the value ofenableOfflineQueue: