Files
hermes-agent/apps/desktop/electron
Teknium da96a9c204 fix(desktop): never lose HERMES_BACKEND_READY emitted before the port wait attaches
The spawn-time output tail (#93608) puts child stdout into flowing mode at
spawn. Both backend spawn paths in main.ts then await claimBackendChild
(whose Windows Get-Process probe cold-starts in 2-8s) and boot-progress IPC
BEFORE waitForDashboardPortAnnouncement attaches its stdout listener. Node
streams never replay consumed chunks to late listeners, so a READY sentinel
printed during that window was lost forever — the wait hit its 90s timeout
and a healthy backend was killed (deterministic on Windows, racy on
macOS/Linux; still firing on v0.21.0 incl. concurrent multi-profile boots).

Fix (belt and suspenders, both spawn paths — primary and profile pool):
- create the port-announcement promise immediately after spawn, before any
  await
- new bufferedOutput option on waitForDashboardPortAnnouncement: after
  attaching its own listener, waitForDashboardPort scans the output tail's
  already-buffered text for the sentinel, making listener-attach ordering
  irrelevant regardless of call-site shape

The readyFile path was already ordering-safe (it polls a file, not the
stream). Approach follows stale PR #60986 by @ParaWheeler, rebased onto the
output-tail/readyFile plumbing added since.

Fixes #60323
2026-09-01 08:30:21 -07:00
..