You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
fix: always emit an error when the connection drops
This commit is contained in:
@@ -153,7 +153,7 @@ describe('connection tests', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.skip('can not connect with wrong host / port in the options object', (done) => {
|
||||
it('can not connect with wrong host / port in the options object', (done) => {
|
||||
const options = {
|
||||
host: 'somewhere',
|
||||
port: 6379,
|
||||
@@ -163,11 +163,10 @@ describe('connection tests', () => {
|
||||
client = Redis.createClient(options)
|
||||
assert.strictEqual(client._connectionOptions.family, ip === 'IPv6' ? 6 : 4)
|
||||
assert.strictEqual(Object.keys(options).length, 4)
|
||||
const end = helper.callFuncAfter(done, 2)
|
||||
|
||||
client.on('error', (err) => {
|
||||
assert(/CONNECTION_BROKEN|ENOTFOUND|EAI_AGAIN/.test(err.code))
|
||||
end()
|
||||
assert(/NR_CLOSED/.test(err.code))
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -206,7 +205,7 @@ describe('connection tests', () => {
|
||||
},
|
||||
port: 9999
|
||||
})
|
||||
client.on('error', helper.isError(/Redis connection to 127\.0\.0\.1:9999 failed/))
|
||||
client.on('error', helper.isError(/Redis connection ended/))
|
||||
})
|
||||
|
||||
it('retryStrategy used to reconnect with defaults', (done) => {
|
||||
@@ -230,6 +229,7 @@ describe('connection tests', () => {
|
||||
setTimeout(() => {
|
||||
client._stream.destroy()
|
||||
}, 50)
|
||||
client.on('error', helper.isError(/Redis connection ended/))
|
||||
})
|
||||
})
|
||||
|
||||
|
@@ -194,7 +194,7 @@ describe('The \'multi\' method', () => {
|
||||
})
|
||||
|
||||
describe('when connection is broken', () => {
|
||||
it.skip('return an error even if connection is in broken mode', (done) => {
|
||||
it('return an error even if connection is in broken mode', (done) => {
|
||||
client = redis.createClient({
|
||||
host: 'somewhere',
|
||||
port: 6379,
|
||||
@@ -202,13 +202,12 @@ describe('The \'multi\' method', () => {
|
||||
})
|
||||
|
||||
client.on('error', (err) => {
|
||||
if (/Redis connection in broken state/.test(err.message)) {
|
||||
done()
|
||||
}
|
||||
assert.strictEqual(err.code, 'NR_CLOSED')
|
||||
done()
|
||||
})
|
||||
|
||||
client.multi([['set', 'foo', 'bar'], ['get', 'foo']]).exec().catch((err) => {
|
||||
// assert(/Redis connection in broken state/.test(err.message));
|
||||
assert(/Stream connection ended and command aborted/.test(err.message))
|
||||
assert.strictEqual(err.errors.length, 2)
|
||||
assert.strictEqual(err.errors[0].args.length, 2)
|
||||
})
|
||||
|
@@ -507,8 +507,7 @@ describe('The nodeRedis client', () => {
|
||||
}, 50)
|
||||
})
|
||||
|
||||
// TODO: Fix this by adding the CONNECTION_BROKEN back in
|
||||
it.skip('enqueues operation and keep the queue while trying to reconnect', (done) => {
|
||||
it('enqueues operation and keep the queue while trying to reconnect', (done) => {
|
||||
client = redis.createClient(9999, null, {
|
||||
retryStrategy (options) {
|
||||
if (options.attempt < 4) {
|
||||
@@ -519,7 +518,6 @@ describe('The nodeRedis client', () => {
|
||||
let i = 0
|
||||
|
||||
client.on('error', (err) => {
|
||||
console.log(err)
|
||||
if (err.code === 'NR_CLOSED') {
|
||||
assert(i, 3)
|
||||
assert.strictEqual(client.offlineQueue.length, 0)
|
||||
|
Reference in New Issue
Block a user