Registry / messaging / node-redis-eventbus

node-redis-eventbus

JSON →
library1.2.1jsnpmunverified

A simple event bus powered by node-redis for inter-process communication between multiple Node.js instances using Redis pub/sub. Current stable version is 1.2.1. It provides a lightweight API with async/await and promise patterns, TypeScript definitions included. Differentiators include a static registry for named event bus instances, a ping method to check listener availability, and automatic cleanup. Low release cadence; last update was 2018.

npm install node-redis-eventbus
INSTALL
IMPORT
SIG · NODE-REDIS-EVENTBU
N
node-redis-eventbus
messagingjavascriptv1.2.1
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.

EventBus
import { EventBus } from 'node-redis-eventbus'
const EventBus = require('node-redis-eventbus').EventBus;
Named export; do not use default import. CommonJS requires destructuring.
default
import { EventBus } from 'node-redis-eventbus'
import EventBus from 'node-redis-eventbus'
Package does not have a default export; use named import.
EventBus type
import type { EventBus } from 'node-redis-eventbus'
import { EventBus } from 'node-redis-eventbus' (if only type needed)
If only using types, use `import type` to avoid side effects.
create
EventBus.create(name, opts)
new EventBus(name, opts)
EventBus.create is a static factory method that returns a Promise<EventBus>. Do not use constructor.

Creates an event bus, listens for 'message' events, emits a message, pings listeners, and destroys the bus.

import { EventBus } from 'node-redis-eventbus'; (async () => { const eventBus = await EventBus.create('myBus', { host: process.env.REDIS_HOST ?? 'localhost' }); await eventBus.on<string>('message', (payload) => { console.log('Received:', payload); }); console.log('Listening...'); eventBus.emit('message', 'Hello World'); setTimeout(async () => { const alive = await eventBus.ping(1000, 1); console.log('Alive:', alive); eventBus.destory(); }, 100); })();
Debug
Known issues
gotchaEventBus.create expects a unique name; using duplicate name will not create a new bus but return existing one.
fix
Use EventBus.create only once per name; retrieve later with EventBus.getByName.
affects: >=1.0.0
gotchaThe method `destroy` is misspelled as `destory` in the API.
fix
Call `eventBus.destory()` (note the typo).
affects: <=1.2.1
deprecatedPackage has not been updated since 2018 and may rely on old node-redis versions.
fix
Consider migrating to a maintained alternative like ioredis-based event bus.
affects: 1.2.1
gotchaEventBus is not a singleton; many instances with different names can exist and they share the same Redis connection?
fix
Ensure proper cleanup by calling destory() to avoid resource leaks.
affects: >=1.0.0
gotchaThe `emit` method does not return a Promise; it is fire-and-forget.
fix
Do not await emit(); it returns void.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: EventBus is not a constructor
Trying to use `new EventBus()` instead of static factory method.
fix
Use `await EventBus.create('name')` instead.
Cannot find name 'EventBus'
Forgetting to import or using default import incorrectly.
fix
Import using `import { EventBus } from 'node-redis-eventbus'`
Error: getaddrinfo ENOTFOUND redis
Redis host not configured or unreachable.
fix
Set environment variable REDIS_HOST or pass host in clientOpts.
TimeoutError: ping timed out
No listeners responded within the timeout.
fix
Ensure at least one listener is active or increase timeout / minResponseCount.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
redisrequiredRequired for Redis client connectivity and pub/sub functionality
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
node-redis-eventbus — npm install node-redis-eventbus · libregistry