-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Node: v12.18.2
redis: 5.0.5 (docker image)
async-redis: 2.0.0
Error occur as " AbortError: BLPOP can't be processed. The connection is already closed. "
This is ample code where an error occurs.
const redis = require('async-redis')
let client = redis.createClient("redis://localhost:6379");
let cnt = 0;
async function reconnect() {
try {
await client.quit()
client = null
client = redis.createClient("redis://localhost:6379");
console.log('reconnect');
} catch (error) {
console.log(error);
}
}
(async () => {
while (true) {
try {
cnt++
const v = await client.blpop('*', 1)
if (cnt%5 === 0) {
throw Error("Test")
}
} catch (error) {
console.error(error);
await reconnect()
}
}
})()
But below code work well.
There seems to be a problem with clients with the same option as they connected before.
is it bug?
const redis = require('async-redis')
let client = redis.createClient("redis://localhost:6379");
let cnt = 0;
async function reconnect() {
try {
await client.quit()
client = null
client = redis.createClient("redis://localhost:6379", {
customOption: Date.now(), // Here
});
console.log('reconnect');
} catch (error) {
console.log(error);
}
}
(async () => {
while (true) {
try {
cnt++
const v = await client.blpop('*', 1)
if (cnt%5 === 0) {
throw Error("Test")
}
} catch (error) {
console.error(error);
await reconnect()
}
}
})()
micalevisk and olezhko9
Metadata
Metadata
Assignees
Labels
No labels