Registry / database / node-redis-streams

node-redis-streams

JSON →
library1.1.5jsnpmunverified

Redis Streams Library for Node.js/TypeScript with full consumer group recovery. Version 1.1.5 provides Kafka-like consumer group semantics on top of Redis Streams, including automatic reclaiming of abandoned messages from failed consumers. Key differentiators include batch acknowledgment (XACK), configurable block intervals, and a dedicated reclaim loop. It exposes a Consumer class that wraps XREADGROUP, XACK, and XCLAIM commands. The library is TypeScript-friendly with bundled types. Released under MIT, with no significant recent updates indicating maintenance mode.

npm install node-redis-streams
INSTALL
IMPORT
SIG · NODE-REDIS-STREAMS
N
node-redis-streams
databasejavascriptv1.1.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Consumer
const { Consumer } = require('node-redis-streams')
const nrs = require('node-redis-streams'); const consumer = new nrs.Consumer()
CommonJS pattern; ESM import is not officially documented but may work.
Consumer
import { Consumer } from 'node-redis-streams'
import Consumer from 'node-redis-streams'
Named export, not default. Works with TypeScript and ESM.
IConsumerOptions
import type { IConsumerOptions } from 'node-redis-streams'
Type import for TypeScript users; interface exported as IConsumerOptions.

Creates a Redis Stream consumer group consumer, starts consuming with automatic reclaim, and handles graceful shutdown.

const Redis = require('ioredis'); const { Consumer } = require('node-redis-streams'); const redisClient = new Redis(); const consumer = new Consumer({ consumerName: 'my-consumer', groupName: 'my-group', readItems: 10, recordHandler: async (record) => { console.log('Processing record:', record.id, record.message); }, errorHandler: async (record, err) => { console.error('Error processing record', record.id, err); }, redisClient, streamName: 'my-stream', blockIntervalMS: 1000, checkAbandonedIntervalMS: 5000 }); consumer.StartConsuming().then(() => { console.log('Consuming started'); }); // Graceful shutdown process.on('SIGTERM', async () => { await consumer.StopConsuming(); redisClient.quit(); });
Debug
Known issues
gotchaDo not forget to call StartConsuming() after creating the Consumer instance, or no records will be processed.
fix
Ensure consumer.StartConsuming() is called.
affects: >=0.0.1
gotchaThe recordHandler is called for each record in a batch; all records are XACK'd only after the batch completes. If an error occurs partway, already-processed records are acknowledged (XACK), but the rest are not. This can lead to duplicate processing on restart if records were processed but not XACK'd.
fix
Implement idempotent record processing or use a database to track processed record IDs.
affects: >=0.0.1
gotchaIf you stop the process without calling StopConsuming(), records may remain pending in the consumer group and require manual XCLAIM or XACK.
fix
Always call consumer.StopConsuming() before shutdown, and then quit the Redis client.
affects: >=0.0.1
deprecatedThe 'checkAbandonedMS' option in ConsumerOptions is misspelled; the correct option is 'checkAbandonedIntervalMS'. Using 'checkAbandonedMS' may be silently ignored.
fix
Use 'checkAbandonedIntervalMS' instead of 'checkAbandonedMS'.
affects: <=1.1.5
breakingIn version 1.0.0, the method 'StartConsuming' was renamed from 'startConsuming' (camelCase) to PascalCase. The old name will cause a runtime error if used.
fix
Use 'StartConsuming()' instead of 'startConsuming()'.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: nrs.Consumer is not a constructor
Using default import instead of named import (e.g., import nrs from 'node-redis-streams' instead of import { Consumer } from 'node-redis-streams').
fix
Use named import: import { Consumer } from 'node-redis-streams' (CommonJS: const { Consumer } = require('node-redis-streams')).
RedisClient is not defined
Passing an invalid or non-ioredis client to the Consumer constructor.
fix
Ensure you pass a valid ioredis instance as 'redisClient'.
Error: Consumer group 'my-group' does not exist
The consumer group has not been created on the stream before starting the consumer.
fix
Create the consumer group using XGROUP CREATE or use a library that auto-creates groups.
Unhandled promise rejection: Error: Cannot StartConsuming more than once
Calling StartConsuming() on a Consumer that is already consuming.
fix
Check if consumer is already started (e.g., maintain a flag) or call StopConsuming() before restarting.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies
ioredisrequiredRequired for Redis client instance passed to Consumer constructor.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
node-redis-streams — npm install node-redis-streams · libregistry