Registry / messaging / ioredis-streams

ioredis-streams

JSON →
library2.0.0jsnpmunverified

ioredis-streams is a lightweight Node.js library (v2.0.0) that wraps ioredis to provide event-driven handling of Redis Streams. It allows developers to easily consume and process stream entries using event emitters, simplifying the typical polling or blocking read pattern. The library is TypeScript-ready with included types and is designed for real-time data pipelines. Compared to raw ioredis usage, it reduces boilerplate by automatically handling stream consumer groups, acknowledgments, and error recovery. It targets active development with a focus on stream ingestion and processing use cases. Key differentiators include its event-driven API and integration with ioredis's connection management.

npm install ioredis-streams
INSTALL
IMPORT
SIG · IOREDIS-STREAMS
I
ioredis-streams
messagingjavascriptv2.0.0
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.

StreamProcessor
import { StreamProcessor } from 'ioredis-streams'
const StreamProcessor = require('ioredis-streams')
ESM-only package; requires Node.js with ESM support or bundler. CommonJS require will fail.
StreamProcessor
import { StreamProcessor } from 'ioredis-streams'
import StreamProcessor from 'ioredis-streams'
Default export does not exist. Must use named import.
ConsumerGroup
import { ConsumerGroup } from 'ioredis-streams'
import { ConsumerGroup } from 'ioredis-streams/consumer'
All exports are from the main package entry; no subpath exports.

Shows how to create a StreamProcessor, listen for data events, acknowledge entries, and handle graceful shutdown.

import Redis from 'ioredis'; import { StreamProcessor } from 'ioredis-streams'; const redis = new Redis({ host: 'localhost', port: 6379 }); const processor = new StreamProcessor(redis, { stream: 'mystream', group: 'mygroup', consumer: 'consumer1', blockMs: 5000, }); processor.on('data', (entry) => { console.log('Received entry:', entry.id, entry.message); entry.ack(); }); processor.on('error', (err) => { console.error('Error:', err); }); processor.start(); // Graceful shutdown process.on('SIGINT', async () => { await processor.stop(); redis.disconnect(); });
Debug
Known issues
breakingLibrary is ESM-only; cannot be required with CommonJS require().
fix
Use import syntax or switch to a bundler that supports ESM.
affects: >=2.0.0
gotchaCalling start() without setting up event listeners may cause unhandled errors or memory leaks.
fix
Always attach 'error' listener before start().
affects: >=2.0.0
gotchaConsumer group must exist in Redis before using StreamProcessor; otherwise it will throw.
fix
Create the consumer group manually (XGROUP CREATE) before initializing processor.
affects: >=2.0.0
deprecatedThe 'message' event was renamed to 'data' in v2.0.0; 'message' is deprecated.
fix
Use 'data' event instead of 'message'.
affects: >=2.0.0
gotchaEntry acknowledgment (ack()) must be called for each entry to avoid reprocessing.
fix
Call entry.ack() after successful processing.
affects: >=2.0.0
Errors
Common errors & fixes
ERR wrong number of arguments for 'xgroup' command
Consumer group not created before starting processor.
fix
Run XGROUP CREATE mystream mygroup $ MKSTREAM in Redis CLI before starting processor.
TypeError: ioRedisStreams_1.StreamProcessor is not a constructor
Trying to use default import instead of named import.
fix
Change to import { StreamProcessor } from 'ioredis-streams'.
SyntaxError: Unexpected token 'export'
Attempting to require() an ESM-only package in a CommonJS file.
fix
Use import syntax or set type: 'module' in package.json.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
ioredisrequiredrequired for Redis connection and stream commands
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
ioredis-streams — npm install ioredis-streams · libregistry