Skip to content

Commit 18ec52d

Browse files
authored
fix #2044 - handle "isolated clients" errors (#2059)
1 parent f6f645b commit 18ec52d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/client/lib/client/index.spec.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,11 @@ describe('Client', () => {
477477
assert.ok(id !== isolatedId);
478478
}, GLOBAL.SERVERS.OPEN);
479479

480-
async function killClient<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>): Promise<void> {
481-
const onceErrorPromise = once(client, 'error');
480+
async function killClient<M extends RedisModules, S extends RedisScripts>(
481+
client: RedisClientType<M, S>,
482+
errorClient: RedisClientType<M, S> = client
483+
): Promise<void> {
484+
const onceErrorPromise = once(errorClient, 'error');
482485
await client.sendCommand(['QUIT']);
483486
await Promise.all([
484487
onceErrorPromise,
@@ -503,6 +506,10 @@ describe('Client', () => {
503506
minimumDockerVersion: [6, 2] // CLIENT INFO
504507
});
505508

509+
testUtils.testWithClient('should propagated errors from "isolated" clients', client => {
510+
return client.executeIsolated(isolated => killClient(isolated, client));
511+
}, GLOBAL.SERVERS.OPEN);
512+
506513
testUtils.testWithClient('scanIterator', async client => {
507514
const promises = [],
508515
keys = new Set();

packages/client/lib/client/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
189189
create: async () => {
190190
const duplicate = this.duplicate({
191191
isolationPoolOptions: undefined
192-
});
192+
}).on('error', err => this.emit('error', err));
193193
await duplicate.connect();
194194
return duplicate;
195195
},

0 commit comments

Comments
 (0)