Skip to content

fix(gateway): Windows compatibility fixes - #8180

Closed
XiaoXiao0221 wants to merge 1 commit into
NousResearch:mainfrom
XiaoXiao0221:fix/windows-gateway-encoding-v2
Closed

fix(gateway): Windows compatibility fixes#8180
XiaoXiao0221 wants to merge 1 commit into
NousResearch:mainfrom
XiaoXiao0221:fix/windows-gateway-encoding-v2

Conversation

@XiaoXiao0221

@XiaoXiao0221 XiaoXiao0221 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR narrows the Windows gateway compatibility fix to gateway-specific issues only.

It fixes two Windows failure modes:

  1. gateway/status.py now treats OSError from os.kill(pid, 0) as a stale-process signal, matching Windows behavior where process existence checks can raise OSError instead of ProcessLookupError.
  2. gateway/run.py now installs a temporary UTF-8 stderr handler during early startup on Windows so gateway startup logs do not fail under non-UTF-8 console encodings. The temporary handler is removed immediately after setup_logging() runs, so it does not leave an extra console handler behind.

The previous memory_tool Windows fix has been split out into separate PR #8563 so this PR stays focused on gateway behavior.

Related Issue

No linked issue.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • add Windows-safe OSError handling to gateway/status.py process liveness checks
  • add a temporary UTF-8 bootstrap stderr handler in gateway/run.py for early startup logs on Windows
  • remove the bootstrap handler after setup_logging() so it does not persist into normal runtime logging
  • reconfigure the verbosity stderr handler to UTF-8 as well
  • add focused regression tests for the new Windows OSError handling and bootstrap handler cleanup
  • remove the unrelated memory_tool change from this PR and keep it in PR fix(memory): support Windows memory file locking #8563 instead

How to Test

  1. Run python -m pytest tests/gateway/test_status.py::TestGatewayPidState::test_get_running_pid_treats_oserror_as_stale -q -n 0
  2. Run python -m pytest tests/gateway/test_status.py::TestScopedLocks::test_acquire_scoped_lock_replaces_oserror_record -q -n 0
  3. Run python -m pytest tests/gateway/test_runner_startup_failures.py::test_start_gateway_removes_bootstrap_stderr_handler_after_setup -q -n 0
  4. Optionally re-run existing nearby regressions:
    • python -m pytest tests/gateway/test_runner_startup_failures.py::test_start_gateway_verbosity_imports_redacting_formatter -q -n 0
    • python -m pytest tests/gateway/test_runner_startup_failures.py::test_start_gateway_replace_force_uses_terminate_pid -q -n 0
    • python -m pytest tests/gateway/test_status.py::TestScopedLocks::test_acquire_scoped_lock_replaces_stale_record -q -n 0

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11 (PowerShell 7)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • tests/gateway/test_status.py::TestGatewayPidState::test_get_running_pid_treats_oserror_as_stale -> passed
  • tests/gateway/test_status.py::TestScopedLocks::test_acquire_scoped_lock_replaces_oserror_record -> passed
  • tests/gateway/test_runner_startup_failures.py::test_start_gateway_removes_bootstrap_stderr_handler_after_setup -> passed
  • tests/gateway/test_runner_startup_failures.py::test_start_gateway_verbosity_imports_redacting_formatter -> passed
  • tests/gateway/test_runner_startup_failures.py::test_start_gateway_replace_force_uses_terminate_pid -> passed
  • tests/gateway/test_status.py::TestScopedLocks::test_acquire_scoped_lock_replaces_stale_record -> passed
  • Running whole gateway test files together in this Windows environment intermittently hit pytest session teardown instability (KeyboardInterrupt / asyncio cleanup), so the validated results above are from focused test invocations

@XiaoXiao0221
XiaoXiao0221 force-pushed the fix/windows-gateway-encoding-v2 branch from 410d0ae to b8d3aef Compare April 15, 2026 15:06
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 28, 2026
@teknium1

teknium1 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for this — appreciate the work. We're closing the entire cluster of open native-Windows PRs (44 of them spanning installer, terminal routing, file ops, gateway PID handling, encoding, docs, and more) because the surface area needs a designed, consolidated approach rather than piecemeal merges. Cherry-picking individual fixes keeps leaving inconsistencies and we'd rather land Windows support properly, in one coherent pass.\n\nYour PR is catalogued in our internal Windows support plan. When we pick this back up (soon), we'll mine every PR in the cluster for its fix shape and credit all contributors whose work informs the final patch via lines. Watch for the consolidating PR and feel free to chime in with context on the specific failure mode you were hitting.\n\nClosing for now, not as a rejection of the fix — just queueing it for the designed rollout. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants