Registry / devops / redis-heartbeat

redis-heartbeat

JSON →
library1.0.0jsnpmunverified

Pulse a heartbeat to Redis for service discovery, load balancer attachment/detachment (e.g., nginx). Version 1.0.0 (latest stable) dropped metrics support and coffee-script 2, requiring Node >= 6. Low-frequency release; last updated in 2018. Compared to alternatives like 'redis-hb' or custom SETEX loops, this library provides configurable intervals, expiration, Redis time usage, disk space checking, and optional existing client injection.

npm install redis-heartbeat
INSTALL
IMPORT
SIG · REDIS-HEARTBEAT
R
redis-heartbeat
devopsjavascriptv1.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.

default
✓ const Heartbeat = require('redis-heartbeat'); new Heartbeat(options);
✗ import Heartbeat from 'redis-heartbeat';
Package is CommonJS only; no ESM exports.
Heartbeat
✓ const { Heartbeat } = require('redis-heartbeat');
✗ import { Heartbeat } from 'redis-heartbeat';
Not a named export; library exports a constructor directly.
require('redis-heartbeat')
✓ const Heartbeat = require('redis-heartbeat');
✗ const Heartbeat = require('redis-heartbeat').default;
There is no .default property; direct require returns the constructor.

Creates a heartbeat instance, starts sending periodic pulses to Redis, and stops after 10 seconds.

const Heartbeat = require('redis-heartbeat'); const hb = new Heartbeat({ name: 'my-service', identifier: 'http://instance-1:8080', intervalHeartbeat: 5, host: process.env.REDIS_HOST || '127.0.0.1', port: parseInt(process.env.REDIS_PORT, 10) || 6379 }); hb.on('started', () => console.log('Heartbeat started')); hb.on('error', err => console.error('Heartbeat error:', err)); // Start heartbeat (autostart: true by default) hb.start(); // Later: stop and quit setTimeout(() => { hb.stop(); hb.quit(); }, 10000);
Debug
Known issues
breakingVersion 1.0.0 drops metrics support and drops Node < 6.
fix
Ensure Node >= 6.0.0. For metrics, do not upgrade from 0.x.
affects: >=1.0.0
deprecatedcoffee-script 2 is used internally; vulnerable to malicious package squatting (regression).
fix
Pin to version 1.0.0 or avoid unless necessary.
affects: >=1.0.0
gotchaIf 'client' option is provided, host/port/options are ignored. Misconfiguring both can lead to connecting to wrong Redis.
fix
Provide either a full Redis client or host/port/options, not both inadvertently.
affects: *
gotchaautostart defaults to true; if not handled, heartbeat starts immediately without event listeners.
fix
Set autostart: false and manually call .start() after attaching error listener.
affects: *
breakingheartbeatExpire default is 172800 seconds (2 days); if set to 0, key never expires (can fill Redis).
fix
Set heartbeatExpire to a reasonable value for your use case.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'redis-heartbeat'
Package not installed or Node version < 6.
fix
Run 'npm install redis-heartbeat' and ensure Node >= 6.0.0.
TypeError: Heartbeat is not a constructor
Importing as ESM named export instead of CommonJS require.
fix
Use const Heartbeat = require('redis-heartbeat');
TypeError: hb.on is not a function
hb is undefined because module didn't export constructor properly (e.g., wrong import).
fix
Verify import: const Heartbeat = require('redis-heartbeat'); then const hb = new Heartbeat(options);
Error: heartbeat not initialized
Cannot call start/stop before instance creation or after quit().
fix
Ensure hb is a valid Heartbeat instance and not quitted.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
redisoptionalRedis client for heartbeat storage
diskusageoptionalDisk space check if diskCheckPath option is set
Agent activity
4 hits · last 30 days
node
4
Resources
redis-heartbeat — npm install redis-heartbeat · libregistry