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

Fix: XAUTOCLAIM after a TRIM with pending messages returns nil (#2565)

* fix(client): XCLAIM & XAUTOCLAIM after a TRIM might return nils

* fix(client): Fix race condition in specs

* revert test utils changes

* make tests faster

---------

Co-authored-by: Leibale Eidelman <me@leibale.com>
This commit is contained in:
Charley DAVID
2023-09-19 23:37:16 +02:00
committed by GitHub
parent 4ec97be4f0
commit e00041e0eb
6 changed files with 154 additions and 27 deletions

View File

@@ -83,8 +83,38 @@ describe('XCLAIM', () => {
});
assert.deepEqual(
await client.xClaim('key', 'group', 'consumer', 1, '0-0'),
await client.xClaim('key', 'group', 'consumer', 0, '0-0'),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('client.xClaim with a message', async client => {
await client.xGroupCreate('key', 'group', '$', { MKSTREAM: true });
const id = await client.xAdd('key', '*', { foo: 'bar' });
await client.xReadGroup('group', 'consumer', { key: 'key', id: '>' });
assert.deepEqual(
await client.xClaim('key', 'group', 'consumer', 0, id),
[{
id,
message: Object.create(null, { 'foo': {
value: 'bar',
configurable: true,
enumerable: true
} })
}]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('client.xClaim with a trimmed message', async client => {
await client.xGroupCreate('key', 'group', '$', { MKSTREAM: true });
const id = await client.xAdd('key', '*', { foo: 'bar' });
await client.xReadGroup('group', 'consumer', { key: 'key', id: '>' });
await client.xTrim('key', 'MAXLEN', 0);
assert.deepEqual(
await client.xClaim('key', 'group', 'consumer', 0, id),
testUtils.isVersionGreaterThan([7, 0]) ? []: [null]
);
}, GLOBAL.SERVERS.OPEN);
});