Skip to content

[Bug]: Windows ocx service repair prints success and failure (exit code 199) after a 2-minute elevated re-registration while the proxy is down #4914

Description

@Awesom-Jack

Client or integration

Codex App

Area

Service lifecycle

Summary

On Windows, ocx service repair (2.57.0) run against a Task Scheduler service that 2.48.0 had installed ran for 2 min 08 s, then printed a success line and a failure line for the same run:

  • stdout: ✅ opencodex service repaired and serving on port 10100.
  • stderr: ❌ Service repair failed: Background service install failed with exit code 199.

Nothing listened on port 10100 while it ran, so every Codex App request failed for about 2 minutes. When it finished, the task definition returned by schtasks /query /tn opencodex-proxy /xml was identical to the one before the repair (apart from blank lines), and the service was healthy: /readyz reported ready with version 2.57.0, and ocx service status printed ✅ service installed (Task Scheduler).

Expected: a single, truthful outcome. If the elevated re-registration does not complete and the existing definition is restarted, say so, for example with a warning that the registration was kept. Do not report success and failure together. The elevation wait should also not keep the proxy down, for example by asking for elevation before the task is stopped.

Context from reading src/service/repair.ts, which is identical on dev at 5061f2c95:

  • repairService calls stopWindows() before reregisterWindowsSchedulerTask, so the port stays closed for as long as the elevated fallback waits.
  • The existing task was created without elevation by ocx service install 2.48.0 (RunLevel LeastPrivilege, LogonType InteractiveToken, Priority 4). Its triggers name the account (<UserId>MACHINE\user</UserId>) instead of the SID. My guess is that this triggered identityUpgradeNeeded and the re-registration. I have not verified this.
  • Exit code 199 is neither OCX_ELEVATED_UAC_CANCELLED (1223) nor OCX_ELEVATED_PROTOCOL_FAILED (13), and I could not find where it comes from. Nobody was at the console, so a UAC prompt, if one appeared, went unanswered. consent.exe was no longer running afterwards.

Reproduction

Observed once. I did not repeat it to avoid a second outage.

  1. On Windows 10 22H2, as a standard user with UAC enabled: npm install --prefix D:\ocx\runtime @bitkyc08/opencodex@2.48.0, then ocx service install (Task Scheduler backend).
  2. End the service process tree (wscript → cmd → bun), then replace D:\ocx\runtime with a 2.57.0 install at the same path.
  3. With the same OPENCODEX_HOME and CODEX_HOME, run ocx service repair and leave the console unattended.
  4. Result: about 2 minutes with port 10100 closed, then both lines above. The registered task XML is unchanged, and the service runs 2.57.0.

In step 2 I stopped the processes myself before running repair. Repair's own flow ends the task first (stopWindows), so the outage should match without that manual step.

Version

2.57.0 (repair), on a service installed by 2.48.0. Bundled Bun 1.4.0.

Operating system

Windows 10 22H2 (10.0.19045)

Provider and model

Not provider-specific (the proxy routes openai / gpt-5.6-sol and zai / glm-5.3).

Logs or error output

[2026-09-17T16:44:57.471Z] ocx service repair started (ocx.cmd, 2.57.0)
[17/09/2026 18:47:02,68] opencodex service wrapper start          <- service.log, local time = 16:47:02Z
[2026-09-17T16:47:05.553Z] stdout: ✅ opencodex service repaired and serving on port 10100.
[2026-09-17T16:47:05.553Z] stderr: ❌ Service repair failed: Background service install failed with exit code 199.

The process exit code of ocx.cmd was not captured (PowerShell Start-Process -RedirectStandardOutput returned a null ExitCode).

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCLI, config inject, packaging flagsinstallInstallation or packagingplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)serviceService lifecycle (WinSW/launchd/scheduler)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions