{"id":46112,"library":"redis-heartbeat","title":"redis-heartbeat","description":"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.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mpneuried/redis-heartbeat","tags":["javascript"],"install":[{"cmd":"npm install redis-heartbeat","lang":"bash","label":"npm"},{"cmd":"yarn add redis-heartbeat","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-heartbeat","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Redis client for heartbeat storage","package":"redis","optional":true},{"reason":"Disk space check if diskCheckPath option is set","package":"diskusage","optional":true}],"imports":[{"note":"Package is CommonJS only; no ESM exports.","wrong":"import Heartbeat from 'redis-heartbeat';","symbol":"default","correct":"const Heartbeat = require('redis-heartbeat'); new Heartbeat(options);"},{"note":"Not a named export; library exports a constructor directly.","wrong":"import { Heartbeat } from 'redis-heartbeat';","symbol":"Heartbeat","correct":"const { Heartbeat } = require('redis-heartbeat');"},{"note":"There is no .default property; direct require returns the constructor.","wrong":"const Heartbeat = require('redis-heartbeat').default;","symbol":"require('redis-heartbeat')","correct":"const Heartbeat = require('redis-heartbeat');"}],"quickstart":{"code":"const Heartbeat = require('redis-heartbeat');\n\nconst hb = new Heartbeat({\n  name: 'my-service',\n  identifier: 'http://instance-1:8080',\n  intervalHeartbeat: 5,\n  host: process.env.REDIS_HOST || '127.0.0.1',\n  port: parseInt(process.env.REDIS_PORT, 10) || 6379\n});\n\nhb.on('started', () => console.log('Heartbeat started'));\nhb.on('error', err => console.error('Heartbeat error:', err));\n\n// Start heartbeat (autostart: true by default)\nhb.start();\n\n// Later: stop and quit\nsetTimeout(() => {\n  hb.stop();\n  hb.quit();\n}, 10000);","lang":"javascript","description":"Creates a heartbeat instance, starts sending periodic pulses to Redis, and stops after 10 seconds."},"warnings":[{"fix":"Ensure Node >= 6.0.0. For metrics, do not upgrade from 0.x.","message":"Version 1.0.0 drops metrics support and drops Node < 6.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Pin to version 1.0.0 or avoid unless necessary.","message":"coffee-script 2 is used internally; vulnerable to malicious package squatting (regression).","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Provide either a full Redis client or host/port/options, not both inadvertently.","message":"If 'client' option is provided, host/port/options are ignored. Misconfiguring both can lead to connecting to wrong Redis.","severity":"gotcha","affected_versions":"*"},{"fix":"Set autostart: false and manually call .start() after attaching error listener.","message":"autostart defaults to true; if not handled, heartbeat starts immediately without event listeners.","severity":"gotcha","affected_versions":"*"},{"fix":"Set heartbeatExpire to a reasonable value for your use case.","message":"heartbeatExpire default is 172800 seconds (2 days); if set to 0, key never expires (can fill Redis).","severity":"breaking","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.0.0':18 '2':28 '2018':39 '6':31 'altern':42 'attachment/detachment':14 'balanc':13 'check':62 'client':66 'coffe':26 'coffee-script':25 'compar':40 'configur':54 'custom':48 'discoveri':11 'disk':60 'drop':21 'e.g':15 'exist':65 'expir':56 'frequenc':34 'hb':46 'heartbeat':3,6 'inject':67 'interv':55 'javascript':68 'last':36 'latest':19 'librari':52 'like':43 'load':12 'loop':50 'low':33 'low-frequ':32 'metric':22 'nginx':16 'node':30 'option':64 'provid':53 'puls':4 'redi':2,8,45,57 'redis-hb':44 'redis-heartbeat':1 'releas':35 'requir':29 'script':27 'servic':10 'setex':49 'space':61 'stabl':20 'support':23 'time':58 'updat':37 'usag':59 'version':17","created_at":"2026-06-07T12:58:20.784642+00:00","updated_at":"2026-06-07T12:58:20.784642+00:00","problems":[{"fix":"Run 'npm install redis-heartbeat' and ensure Node >= 6.0.0.","cause":"Package not installed or Node version < 6.","error":"Error: Cannot find module 'redis-heartbeat'"},{"fix":"Use const Heartbeat = require('redis-heartbeat');","cause":"Importing as ESM named export instead of CommonJS require.","error":"TypeError: Heartbeat is not a constructor"},{"fix":"Verify import: const Heartbeat = require('redis-heartbeat'); then const hb = new Heartbeat(options);","cause":"hb is undefined because module didn't export constructor properly (e.g., wrong import).","error":"TypeError: hb.on is not a function"},{"fix":"Ensure hb is a valid Heartbeat instance and not quitted.","cause":"Cannot call start/stop before instance creation or after quit().","error":"Error: heartbeat not initialized"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mpneuried/redis-heartbeat","github":"https://github.com/mpneuried/redis-heartbeat","docs":null,"changelog":null,"pypi":null,"npm":"redis-heartbeat","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}