Skip to content

fix(transit): seq/instanceID heartbeat checks (Node.js parity) - #41

Merged
explosivebit merged 1 commit into
devfrom
fix/heartbeat-seq-instanceid
Apr 7, 2026
Merged

explosivebit merged 1 commit into
devfrom
fix/heartbeat-seq-instanceid

Conversation

@explosivebit

Copy link
Copy Markdown
Contributor

Summary

Implements seq/instanceID checks in heartbeat handler matching Node.js Moleculer heartbeatReceived():

  • seq mismatch → services changed on remote node → trigger re-discovery
  • instanceID mismatch → node restarted → trigger re-discovery
  • heartbeat payload now includes seq and instanceID fields

Without this, a remote node that restarts or changes services is never re-discovered via heartbeat — only via the slower INFO round-trip.

Evidence

Step Result
ruff + mypy ✅ 0 errors
pytest ✅ 2358 passed
demo_matrix ✅ 28/28
demo_comprehensive ✅ 90/90

Test plan

  • test_heartbeat_seq_mismatch_triggers_discover
  • test_heartbeat_instanceid_mismatch_triggers_discover
  • test_heartbeat_same_seq_instanceid_updates_metrics

🤖 Generated with Claude Code

…ity)

Matches Node.js Moleculer base discoverer heartbeatReceived():
- seq mismatch → services changed on remote node → request fresh INFO
- instanceID mismatch → node restarted → request fresh INFO
- Also includes seq/instanceID in heartbeat payload so remote Python
  nodes can detect changes without waiting for INFO round-trip

Refs: Node.js base.js:205-229

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
moleculerpy/transit.py 93.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@explosivebit
explosivebit merged commit 433ded0 into dev Apr 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant