You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
fix(client): make unstable cmds throw (#2990)
As per the docs, unstableResp3 commands should throw when client is created with { RESP: 3, unstableResp3: false|undefined } fixes #2989
This commit is contained in:
committed by
GitHub
parent
ca91718b59
commit
62ac8b7c32
@@ -38,7 +38,11 @@ export function attachConfig<
|
||||
Class: any = class extends BaseClass {};
|
||||
|
||||
for (const [name, command] of Object.entries(commands)) {
|
||||
Class.prototype[name] = createCommand(command, RESP);
|
||||
if (config?.RESP == 3 && command.unstableResp3 && !config.unstableResp3) {
|
||||
Class.prototype[name] = throwResp3SearchModuleUnstableError;
|
||||
} else {
|
||||
Class.prototype[name] = createCommand(command, RESP);
|
||||
}
|
||||
}
|
||||
|
||||
if (config?.modules) {
|
||||
|
@@ -131,4 +131,37 @@ describe('XREAD', () => {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.xRead should throw with resp3 and unstableResp3: false', async client => {
|
||||
assert.throws(
|
||||
() => client.xRead({
|
||||
key: 'key',
|
||||
id: '0-0'
|
||||
}),
|
||||
{
|
||||
message: 'Some RESP3 results for Redis Query Engine responses may change. Refer to the readme for guidance'
|
||||
}
|
||||
);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.xRead should not throw with resp3 and unstableResp3: true', async client => {
|
||||
assert.doesNotThrow(
|
||||
() => client.xRead({
|
||||
key: 'key',
|
||||
id: '0-0'
|
||||
})
|
||||
);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3,
|
||||
unstableResp3: true
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -155,4 +155,36 @@ describe('XREADGROUP', () => {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.xReadGroup should throw with resp3 and unstableResp3: false', async client => {
|
||||
assert.throws(
|
||||
() => client.xReadGroup('group', 'consumer', {
|
||||
key: 'key',
|
||||
id: '>'
|
||||
}),
|
||||
{
|
||||
message: 'Some RESP3 results for Redis Query Engine responses may change. Refer to the readme for guidance'
|
||||
}
|
||||
);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.xReadGroup should not throw with resp3 and unstableResp3: true', async client => {
|
||||
assert.doesNotThrow(
|
||||
() => client.xReadGroup('group', 'consumer', {
|
||||
key: 'key',
|
||||
id: '>'
|
||||
})
|
||||
);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3,
|
||||
unstableResp3: true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user