Skip to content

Commit 3aa2b40

Browse files
committed
feat: update ioredis to 5x
BREAKING: no support for node < 14. ioredis update
1 parent 8798ca8 commit 3aa2b40

File tree

3 files changed

+59
-56
lines changed

3 files changed

+59
-56
lines changed

package-lock.json

Lines changed: 43 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@
3737
},
3838
"dependencies": {
3939
"debug": "^4.3.4",
40-
"ioredis": "^4.27.2"
41-
},
42-
"peerDependencies": {
43-
"@types/ioredis": "^4"
44-
},
45-
"peerDependenciesMeta": {
46-
"@types/ioredis": {
47-
"optional": true
48-
}
40+
"ioredis": "^5.2.3"
4941
},
5042
"devDependencies": {
5143
"@calebboyd/semantic-release-config": "^1.0.1",

src/redis.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Pipeline } from 'ioredis'
1+
import { ChainableCommander } from 'ioredis'
22
import { RedisStream } from './stream.js'
33
import mkDebug from 'debug'
44
import { XBatchResult, XStreamResult } from './types.js'
@@ -21,6 +21,11 @@ export async function readAckDelete(
2121
ack(pipeline, stream)
2222
read(pipeline, stream)
2323
const responses = await pipeline.exec()
24+
25+
if (!responses) {
26+
return
27+
}
28+
2429
//TODO NOGROUP the consumer group this client was blocked on no longer exists
2530
for (const result of responses) {
2631
if (result[0] && !result[0]?.message.startsWith('BUSYGROUP')) {
@@ -42,7 +47,10 @@ export async function readAckDelete(
4247
}
4348
}
4449

45-
function ack(client: Pipeline, { deleteOnAck, pendingAcks, group }: RedisStream<KindaAny>): void {
50+
function ack(
51+
client: ChainableCommander,
52+
{ deleteOnAck, pendingAcks, group }: RedisStream<KindaAny>
53+
): void {
4654
if (!group || !pendingAcks.size) return
4755
for (const [stream, ids] of pendingAcks) {
4856
client.xack(stream, group, ...ids)
@@ -51,11 +59,14 @@ function ack(client: Pipeline, { deleteOnAck, pendingAcks, group }: RedisStream<
5159
pendingAcks.clear()
5260
}
5361

54-
function xgroup(client: Pipeline, { group, streams, first }: RedisStream<KindaAny>): void {
62+
function xgroup(
63+
client: ChainableCommander,
64+
{ group, streams, first }: RedisStream<KindaAny>
65+
): void {
5566
if (!first || !group) return
5667
for (const [key, start] of streams) {
5768
debug(`xgroup create ${key} ${group} ${start} mkstream`)
58-
client.xgroup('create', key, group, start, 'mkstream')
69+
client.xgroup('CREATE', key, group, start, 'MKSTREAM')
5970
}
6071
}
6172

0 commit comments

Comments
 (0)