fix(gateway): retry detached restart watcher without breakaway (salvage #42993) - #70262
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on 1255932 ℹ️ InfoDesktop E2E visual evidence · View test artifacts · View job1 visual diff. inline evidence upload failed. Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso) |
The Windows /restart watcher's outer Popen spawns the watcher with windows_detach_popen_kwargs() (which carries CREATE_BREAKAWAY_FROM_JOB), but a restrictive parent job object can reject that bit with OSError and the current call has no retry. Preserve the current watcher implementation and add a focused breakaway-denied fallback. Preserved from current main: watcher_python / pythonw.exe selection, the str(restart_after_s) deadline, the scrubbed watcher_env, the intentional no-breakaway inline respawn, and the entire POSIX setsid/bash path. - primary keeps **windows_detach_popen_kwargs() - on OSError, retry the same argv/env with creationflags=windows_detach_flags_without_breakaway() - on dual failure, log a definitive, path-safe warning (interpreter basename + numeric winerror/errno only) and return without crashing Replace the superseded breakaway-first inline design and its AST tests with focused behavioral coverage that drives the real coroutine with a mocked subprocess.Popen (retry, argv/env/DEVNULL preservation, POSIX single-session kwarg, no-breakaway inline respawn, secret-safe logging). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
teknium1
force-pushed
the
salvage/42993-watcher-breakaway-retry
branch
from
July 23, 2026 23:24
64d3c60 to
1255932
Compare
This was referenced Jul 24, 2026
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.
Summary
Salvages PR #42993 by @VerbalChainsaw: the Windows
/restartwatcher spawn now retries once withoutCREATE_BREAKAWAY_FROM_JOBwhen a restrictive parent job object rejects the breakaway bit with ERROR_ACCESS_DENIED — previously the OSError killed the watcher and the gateway restart silently never happened (#42116).Changes
gateway/run.py: try/except OSError around the outer watcher Popen, single retry withwindows_detach_flags_without_breakaway(), path-safe warning on dual failure (interpreter basename + numeric error only). Mirrors the canonical fallback ingateway_windows._spawn_detached.tests/tools/test_windows_native_support.py: 4 behavioral tests (retry-once, argv/env preservation, no-leak logging, happy-path single spawn).contributors/emails/phixxation@gmail.com: contributor mapping.Validation
test_windows_native_support.py+test_restart_drain.pyAuthorship preserved via cherry-pick; rebase-merge. Duplicate #42242 (same root cause, first diagnosis by @worlldz) was closed with credit — its branch was stale/mixed and hard-coded the now-banned
DETACHED_PROCESS.Closes #42993. Fixes #42116.
Infographic