Registry / database / ion-streamer

ion-streamer

JSON →
library1.3.3jsnpmunverified

ION Streamer (v1.3.3) is a Node.js library for producing and consuming Redis streams in a non-blocking manner. It listens to Redis stream entries in a subprocess, enabling async/await-based processing without blocking the main event loop. Released in 2023, it provides a simple API for stream production and consumption with built-in auto-reconnection. The library differentiates itself by leveraging subprocess isolation for stream consumers, preventing backpressure issues, and supports both Node.js and browser environments via the same API.

npm install ion-streamer
INSTALL
IMPORT
SIG · ION-STREAMER
I
ion-streamer
databasejavascriptv1.3.3
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.

Streamer
import { Streamer } from 'ion-streamer'
const Streamer = require('ion-streamer').Streamer
The library provides named exports; default import is not available. Use named import for ESM.
Consumer
import { Consumer } from 'ion-streamer'
import { Streamer, Consumer } from 'ion-streamer/dist/Consumer'
Path import is not necessary; the main entry re-exports all classes.
Streamer
const { Streamer } = require('ion-streamer')
const streamer = require('ion-streamer')
CJS users must destructure the named export. The default export is undefined.

Demonstrates creating a Streamer and Consumer, producing a stream entry, listening for messages, and handling graceful shutdown with Redis connection.

import { Streamer, Consumer } from 'ion-streamer'; const streamer = new Streamer({ redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379' }); const consumer = new Consumer({ streamKey: 'my-stream', groupName: 'my-group', consumerName: 'worker-1', redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379' }); // Produce a message await streamer.produce('my-stream', { data: 'hello' }); // Consume messages consumer.on('message', (msg) => { console.log(`Received: ${JSON.stringify(msg)}`); return Promise.resolve(); }); await consumer.start(); // Clean up process.on('SIGINT', async () => { await consumer.stop(); await streamer.close(); process.exit(0); });
Debug
Known issues
gotchaConsumer runs in a subprocess, not the same process. This means shared state (e.g., in-memory variables) is not accessible inside the consumer's event handlers.
fix
Use inter-process communication (e.g., send messages via IPC) or avoid relying on shared state. Alternatively, use a different consumer approach if state sharing is required.
affects: <=1.3.3
gotchaThe library does not automatically create the Redis stream or consumer group. You must ensure they exist before producing/consuming.
fix
Run XGROUP CREATE my-stream my-group $ MKSTREAM manually via redis-cli or via the library's Streamer.createGroup() method before starting the consumer.
affects: <=1.3.3
deprecatedThe method 'streamer.send' is deprecated in v1.3.0. Use 'streamer.produce' instead.
fix
Replace streamer.send(...) with streamer.produce(...).
affects: >=1.3.0
gotchaIf Redis connection is lost, the consumer subprocess may exit silently. Auto-reconnect is not implemented for the subprocess consumer.
fix
Implement a health check and restart the consumer on connection loss, or use a more robust library like 'redis-streams-bus' with built-in reconnection.
affects: <=1.3.3
Errors
Common errors & fixes
Error: Consumer group 'my-group' does not exist
The consumer group has not been created for the stream before starting the consumer.
fix
Use streamer.createGroup('my-stream', 'my-group') before consumer.start().
TypeError: streamer.send is not a function
Using the deprecated 'send' method which was removed in v1.3.0.
fix
Use streamer.produce() instead.
Error: Cannot find module 'ion-streamer'
The package is not installed or there is a typo in the import path.
fix
Run npm install ion-streamer and ensure the import is correct (e.g., 'ion-streamer' not 'ion-streamer/src').
Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server is not running or the connection URL is incorrect.
fix
Start Redis server (e.g., docker run -p 6379:6379 redis) or provide correct REDIS_URL environment variable.
Upgrade
Version history
1.3.3latest on npm
Audit
Dependencies
redisrequiredRequired for Redis client interactions. The library wraps the official redis package for stream commands.
uuidoptionalUsed to generate unique stream entry IDs if not provided.
Agent activity
6 hits · last 30 days
node
6
Resources
ion-streamer — npm install ion-streamer · libregistry