Skip to content

Commit b55d858

Browse files
authored
Merge pull request #3085 from RedisInsight/bugfix/release/2.44.0
Bugfix/release/2.44.0
2 parents ea9c26e + d02983f commit b55d858

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

redisinsight/api/src/modules/browser/redisearch/redisearch.service.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ describe('RedisearchService', () => {
8181
describe('list', () => {
8282
it('should get list of indexes for standalone', async () => {
8383
standaloneClient.sendCommand.mockResolvedValue([
84-
keyName1.toString(),
85-
keyName2.toString(),
84+
keyName1,
85+
keyName2,
8686
]);
8787

8888
const list = await service.list(mockBrowserClientMetadata);
@@ -97,8 +97,8 @@ describe('RedisearchService', () => {
9797
it('should get list of indexes for cluster (handle unique index name)', async () => {
9898
databaseClientFactory.getOrCreateClient = jest.fn().mockResolvedValue(clusterClient);
9999
mockStandaloneRedisClient.sendCommand.mockResolvedValue([
100-
keyName1.toString(),
101-
keyName2.toString(),
100+
keyName1,
101+
keyName2,
102102
]);
103103

104104
const list = await service.list(mockBrowserClientMetadata);

redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,18 @@ export class RedisearchService {
4949

5050
try {
5151
const client: RedisClient = await this.databaseClientFactory.getOrCreateClient(clientMetadata);
52-
const nodes = this.getShards(client) as RedisClient[];
52+
const nodes = await this.getShards(client) as RedisClient[];
5353

5454
const res = await Promise.all(nodes.map(async (node) => node.sendCommand(
5555
['FT._LIST'],
5656
)));
5757

5858
return plainToClass(ListRedisearchIndexesResponse, {
59-
indexes: (uniq([].concat(...res))).map((idx) => Buffer.from(idx)),
59+
indexes: (
60+
uniq(
61+
([].concat(...res)).map((idx) => idx.toString('hex')),
62+
)
63+
).map((idx) => Buffer.from(idx, 'hex')),
6064
});
6165
} catch (e) {
6266
this.logger.error('Failed to get redisearch indexes', e);
@@ -100,7 +104,7 @@ export class RedisearchService {
100104
}
101105
}
102106

103-
const nodes = this.getShards(client) as RedisClient[];
107+
const nodes = await this.getShards(client) as RedisClient[];
104108

105109
const commandArgs: any[] = [
106110
index, 'ON', type,
@@ -121,7 +125,7 @@ export class RedisearchService {
121125
...commandArgs,
122126
], { replyEncoding: 'utf8' });
123127
} catch (e) {
124-
if (!e.message.includes('MOVED')) {
128+
if (!e.message.includes('MOVED') && !e.message.includes('already exists')) {
125129
throw e;
126130
}
127131
}
@@ -228,7 +232,7 @@ export class RedisearchService {
228232
* @param client
229233
* @private
230234
*/
231-
private getShards(client: RedisClient): Promise<RedisClient[]> | RedisClient[] {
235+
private async getShards(client: RedisClient): Promise<RedisClient[]> {
232236
if (client.getConnectionType() === RedisClientConnectionType.CLUSTER) {
233237
return client.nodes(RedisClientNodeRole.PRIMARY);
234238
}

0 commit comments

Comments
 (0)