fix: use 'gateway run' on Windows, not 'gateway start' (fixes port-spiral bug)#623
Closed
a2735444 wants to merge 1 commit into
Closed
fix: use 'gateway run' on Windows, not 'gateway start' (fixes port-spiral bug)#623a2735444 wants to merge 1 commit into
a2735444 wants to merge 1 commit into
Conversation
On Windows, `hermes gateway start` only registers a scheduled task and does not actually launch the process. This causes the GatewayManager's health check to always time out, triggering the port-finding spiral bug. Fix: remove 'windows-service' from the needsRunMode exclusion list so Windows also uses `hermes gateway run` as a detached child process, just like WSL and Docker environments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows,
hermes gateway startonly registers a Task Scheduler entry — it does not actually launch the gateway process or wait for it to be ready. This causes the GatewayManager's health check to always time out, which triggersresolvePort()to increment the port number inconfig.yamlon each retry (the "port-spiral" bug). The user sees the gateway as "stopped" indefinitely.Root Cause
detectInitSystem()correctly detects Windows and returns'windows-service'. ButneedsRunModeis defined as:Because
'windows-service'is in the exclusion list, Windows takes thegateway startcode path instead of thegateway runcode path.Fix
Remove
'windows-service'from the exclusion list so Windows also useshermes gateway runas a detached child process (spawn + unref), just like WSL and Docker environments. This is safe on Windows because:spawn(..., { detached: true, windowsHide: true })is fully supportedprocess.kill(pid, 'SIGTERM')on Windows callsTerminateProcessprocess.kill(pid, 0)works for liveliness checksChange
Line 131:
- 'windows-service'removed fromneedsRunModeexclusion array.Testing
hermes gateway runspawns a detached process, writesgateway.pid, health check passes → port stays stablegateway start/stopvia systemd/launchd