1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix #2044 - handle "isolated clients" errors (#2059)

This commit is contained in:
Leibale Eidelman
2022-03-30 06:30:43 -04:00
committed by GitHub
parent f6f645bdbb
commit 18ec52d5ee
2 changed files with 10 additions and 3 deletions

View File

@@ -477,8 +477,11 @@ describe('Client', () => {
assert.ok(id !== isolatedId); assert.ok(id !== isolatedId);
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
async function killClient<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>): Promise<void> { async function killClient<M extends RedisModules, S extends RedisScripts>(
const onceErrorPromise = once(client, 'error'); client: RedisClientType<M, S>,
errorClient: RedisClientType<M, S> = client
): Promise<void> {
const onceErrorPromise = once(errorClient, 'error');
await client.sendCommand(['QUIT']); await client.sendCommand(['QUIT']);
await Promise.all([ await Promise.all([
onceErrorPromise, onceErrorPromise,
@@ -503,6 +506,10 @@ describe('Client', () => {
minimumDockerVersion: [6, 2] // CLIENT INFO minimumDockerVersion: [6, 2] // CLIENT INFO
}); });
testUtils.testWithClient('should propagated errors from "isolated" clients', client => {
return client.executeIsolated(isolated => killClient(isolated, client));
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('scanIterator', async client => { testUtils.testWithClient('scanIterator', async client => {
const promises = [], const promises = [],
keys = new Set(); keys = new Set();

View File

@@ -189,7 +189,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
create: async () => { create: async () => {
const duplicate = this.duplicate({ const duplicate = this.duplicate({
isolationPoolOptions: undefined isolationPoolOptions: undefined
}); }).on('error', err => this.emit('error', err));
await duplicate.connect(); await duplicate.connect();
return duplicate; return duplicate;
}, },