Registry / messaging / redis-pubsub-hook

redis-pubsub-hook

JSON →
library1.0.2jsnpmunverified

Redis pubsub for communicating other nodes in a distributed system, enabling request-response pattern across instances. Current stable version is 1.0.2. Release cadence is low (last release on npm). Key differentiators: built on node-redis and redis-cluster for cluster support; provides a hook mechanism to collect and aggregate data from all nodes; includes namespace support for scoped pubsub channels.

npm install redis-pubsub-hook
INSTALL
IMPORT
SIG · REDIS-PUBSUB-HOOK
R
redis-pubsub-hook
messagingjavascriptv1.0.2
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.

RedisPubSub
import { RedisPubSub } from 'redis-pubsub-hook'
const RedisPubSub = require('redis-pubsub-hook')
ESM import is available since v1.0.0; CommonJS require works but prefer ESM
NamespacePubSub
import { NamespacePubSub } from 'redis-pubsub-hook'
const NamespacePubSub = require('redis-pubsub-hook').NamespacePubSub
NamespacePubSub is a named export; CommonJS require destructuring is incorrect
default
import RedisPubSub from 'redis-pubsub-hook'
const RedisPubSub = require('redis-pubsub-hook').default
Library has a default export which is RedisPubSub; CommonJS users must use .default

Creates a RedisPubSub instance, sets a hook, and makes a request to collect responses from all nodes.

import { RedisPubSub } from 'redis-pubsub-hook'; const pubsub = new RedisPubSub({ redis: process.env.REDIS_URL ?? 'redis://localhost:6379' }); pubsub.setHook('greet', (name: string) => `Hello ${name}`); const responses = await pubsub.request('greet', 'World'); console.log(responses); // ["Hello World"] process.on('SIGINT', () => pubsub.quit());
Debug
Known issues
gotchadefaultCreateClient creates only a single connection; for cluster pass comma-separated URLs.
fix
Use 'redis://host1:6379,host2:6379' for cluster mode.
affects: >=1.0.0
gotchaTimeout default is 3000ms; if not all nodes respond, timeout error may occur.
fix
Set a higher timeout in options if needed.
affects: >=1.0.0
deprecatedThe 'redis' package used as peer dependency is v3; migrating to v4 requires changes.
fix
Use redis v3 for compatibility; the library does not support redis v4.
affects: >=1.0.0
gotchaRequest channel names are hardcoded; ensure no collisions if using multiple pubsub instances.
fix
Use separate Redis databases or unique channel prefixes.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: pubsub.request is not a function
Using default import incorrectly or CommonJS require without .default
fix
Use 'import { RedisPubSub } from 'redis-pubsub-hook'' or 'const { RedisPubSub } = require('redis-pubsub-hook')'
Error: connect ECONNREFUSED 127.0.0.1:6379
No Redis server running at default address
fix
Start a Redis server or set 'redis' option to a valid URL.
TimeoutError: Request timed out after 3000ms
All nodes did not respond within timeout
fix
Increase timeout option or ensure all nodes are reachable.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
redisrequiredPeer dependency for Redis client; the library uses node-redis under the hood
Agent activity
16 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
redis-pubsub-hook — npm install redis-pubsub-hook · libregistry