fix(bridge): start status heartbeat in --daemon mode - #2279
Conversation
PR MemTensor#1998 made the Python launcher prefer the pure-ESM dist/bridge.mjs entry over dist/bridge.cjs, but bridge.mts only calls markConnected()/ startHeartbeat() in its stdio branch. Daemon spawns therefore never refresh bridge-status.json; every reader applies the 20s staleness rule to the fossilized snapshot and reports 'Hermes bridge heartbeat is stale' indefinitely while RPC traffic keeps working. Mirror the legacy bridge.cts daemon path, which always had both calls. Pinned by a source-level regression guard alongside the existing bridge-startup-ordering.test.ts.
🤖 Open Code ReviewTarget: PR #2279 ✅ OpenCodeReview: Review skipped: no items were selected. Generated by cloud-assistant via Open Code Review. |
|
|
Closing in favor of #2280 — it is the more complete upstream fix: dual-entry coverage (the Verified #2280's regression guard ourselves: RED on pristine |
Fix: start the status heartbeat in
--daemonmodeCloses #2278
Problem
#1998 made the Hermes launcher prefer
dist/bridge.mjs, butbridge.mtsonly callsmarkConnected()/startHeartbeat()in its stdio (!args.daemon) branch. Daemon spawns therefore never refreshbridge-status.json; every reader applies the 20s staleness rule to a fossilized snapshot and reports"Hermes bridge heartbeat is stale"indefinitely — while RPC traffic keeps working, since it never touches status tracking.Change
Mirrors the legacy
bridge.ctsdaemon path: after the bind-retry loop succeeds, callBoth calls sit on the success path (after the loop's
break;) so failure exits don't write a false "connected".Plus a source-level regression guard test (
tests/unit/bridge/bridge-daemon-heartbeat.test.ts), following the established pattern ofbridge-startup-ordering.test.ts: the entry point is a top-level executable script, so runtime-testing two call sites doesn't justify refactoring it into an injectable function. The guard scopes to the daemon branch specifically —markConnected()in the stdio branch does not satisfy it.Validation
The new test was verified RED against unpatched
main(fails with "daemon branch never calls markConnected()") and GREEN with this patch.