You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
fix: always emit an error when the connection drops
This commit is contained in:
@ -78,17 +78,20 @@ function reconnect (client, why, error) {
|
||||
timesConnected: client.timesConnected
|
||||
})
|
||||
if (typeof client.retryDelay !== 'number') {
|
||||
// Pass individual error through
|
||||
var err
|
||||
if (client.retryDelay instanceof Error) {
|
||||
error = client.retryDelay
|
||||
}
|
||||
flushAndError(client, 'Stream connection ended and command aborted.', 'NR_CLOSED', {
|
||||
error
|
||||
})
|
||||
// TODO: Check if client is so smart
|
||||
if (error) {
|
||||
client.emit('error', error)
|
||||
// Pass individual error through
|
||||
err = client.retryDelay
|
||||
flushAndError(client, 'Stream connection ended and command aborted.', 'NR_CLOSED', { error: err })
|
||||
} else {
|
||||
flushAndError(client, 'Stream connection ended and command aborted.', 'NR_CLOSED', { error })
|
||||
err = new Errors.RedisError('Redis connection ended.')
|
||||
err.code = 'NR_CLOSED'
|
||||
if (error) {
|
||||
err.origin = error
|
||||
}
|
||||
}
|
||||
client.emit('error', err)
|
||||
client.end(false)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user