mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-18 14:52:04 +00:00
Two fixes to the Electron desktop launch path, with the port-reservation logic extracted into a unit-tested module:
1. hermes:bootstrap:reset ("Reload and retry") only cleared connectionPromise, leaving the live backend alive; the orphan kept binding PORT_FLOOR (9120) so the next startHermes() hit EADDRINUSE / "Object has been destroyed" and the window looped. Await teardownPrimaryBackendAndWait() so the reset stops the old backend before restarting.
2. pickPort() probes-then-closes a socket before the real bind happens in a separate Python child, so two concurrent spawns (primary + pool backend) could both be handed PORT_FLOOR and one died with EADDRINUSE. The reservation bookkeeping is extracted into electron/port-pool.cjs (PortPool): pickPort() reserves the chosen port until the child exits and releases it on every exit/error/throw-before-spawn path, closing the TOCTOU window.
PortPool is dependency-injected (probe passed in) and socket-free, unit-tested in electron/port-pool.test.cjs (8 cases) and wired into the test:desktop:platforms script.
|
||
|---|---|---|
| .. | ||
| backend-probes.cjs | ||
| backend-probes.test.cjs | ||
| bootstrap-platform.cjs | ||
| bootstrap-platform.test.cjs | ||
| bootstrap-runner.cjs | ||
| bootstrap-runner.test.cjs | ||
| connection-config.cjs | ||
| connection-config.test.cjs | ||
| desktop-uninstall.cjs | ||
| desktop-uninstall.test.cjs | ||
| entitlements.mac.inherit.plist | ||
| entitlements.mac.plist | ||
| gateway-ws-probe.cjs | ||
| gateway-ws-probe.test.cjs | ||
| hardening.cjs | ||
| hardening.test.cjs | ||
| main.cjs | ||
| oauth-net-request.cjs | ||
| oauth-net-request.test.cjs | ||
| port-pool.cjs | ||
| port-pool.test.cjs | ||
| preload.cjs | ||