Skip to content

[Bug][Windows] ocx update wedges itself: admission budget counts orphaned teardown receipts with no cap, and a refused admission keeps its own receipt #8960

Closed as not planned

Description

@1666193290-prog

Client or integration

CLI / Updater / Process Control

Area

Windows service stop

Environment

  • OS: Windows 11 x64 (build 26300), zh-CN locale
  • Install: npm global (@bitkyc08/opencodex) under %APPDATA%\npm
  • Service: Task Scheduler task opencodex-proxy
  • Version observed: 2.100.3 → updating to 2.100.5

Summary

ocx update can wedge itself permanently on Windows by an interaction between two
independent mechanisms in the checked stop:

  1. Admission budget counts inherited receipts with no cap. windowsStopWorstCase
    adds inheritedReceipts * 3000 ms on top of a ~53.5 s baseline, against a fixed
    60 s default deadline. Three orphaned receipts are already enough to exceed the
    budget forever. Each further failed attempt adds one more.
  2. A refused admission still leaves this run's own receipt on disk. claimTeardown()
    runs before Part A admission. On refusal the stop sets stopFailed /
    restoreBlocked, so clearRestoredStopReceipts is skipped and the nonce survives —
    even though the refusal means nothing was changed.

Together they form a monotonic loop: retry → more receipts → higher required budget →
guaranteed refusal. The error text tells the operator to run ocx stop, but ocx stop
takes the same admission path and is refused for the same reason. There is no way out
from the CLI as suggested.

Budget arithmetic (measured against the shipped constants)

WINDOWS_STOP_CAPS with Task Scheduler registered, WinSW absent, PID file present:

Step ms
part-a 11000
post-answer 10000
child-exit 18000
part-b 11500
reserve 3000
baseline 53500
inherited-receipts (each) +3000

Against the 60 s default:

receipts=0  need=53500  PASS
receipts=1  need=56500  PASS
receipts=2  need=59500  PASS
receipts=3  need=62500  FAIL
receipts=9  need=80500  FAIL

Note the baseline is 53.5 s, and the design doc (#8546) budgets a 56 s plain stop —
so the real headroom is 4–6.5 s, i.e. two orphaned receipts.

Reproduction

  1. On a Windows machine with the proxy installed as a Task Scheduler service, cause a
    stop to fail in a way that leaves its receipt behind (any stop that does not reach
    restore; in my case an unrelated state-unknown refusal from [Bug][Windows] zh-CN schtasks status makes ocx stop and ocx update fail closed inside the 1s manager-state cap #8863, plus the Codex
    app holding the history DB, which defers the restore and keeps the receipt).
  2. Repeat ocx update two more times. Each attempt claims one more
    pending-teardown-<nonce>.json.
  3. Observe the third attempt fail at admission:
    ⏹  Stopping the running proxy before updating...
    ❌ The installed service manager did not stop; it may respawn the proxy.
       The remaining time cannot hold a verified Windows service stop, so nothing was
       changed; retry from a terminal.
    
  4. Run ocx stop as instructed — it is refused at the same admission check.

Confirmed on disk: 9 receipts, every ownerPid dead, all endpointSource: "exact",
all handover: "update-restart" pointing at the same live proxy port.

What made it recoverable (and why it is not discoverable)

ocx restart goes through the in-place management-API restart, which bypasses
admission entirely
. On the following startup, completeUpdateTeardownHandover →
dischargeUpdateTeardownHandovers drops every abandoned update-restart receipt
whose owner is no longer alive. One ocx restart cleared all 9 receipts in a single
step, and the subsequent ocx update then succeeded.

That recovery path is correct behaviour but is not reachable from the error message.

Suggested fixes

A. Do not let inherited-receipts scale the admission budget without a bound.
The row is a pessimistic estimate; recovering one receipt is a single endpoint probe.
Either cap the row (e.g. min(receipts, N) * probe) or drop it from admission and
charge it against the reserve, so an accumulation of receipts cannot make admission
unsatisfiable on its own.

B. Release this run's own receipt when admission refuses.
A refused admission asserts "nothing was changed". The inherited obligations remain
owed, but the nonce claimed by this run was never backed by an action, so it should
be cleared on that path rather than carried into the next attempt.

C. Make the guidance in the failure message actionable.
When the refusal reason is unverified-budget and abandoned receipts exist, the
message should point at a path that actually works (e.g. "run ocx restart to release
abandoned update handovers, then retry"), rather than ocx stop, which is refused
identically.

Notes

Activity

  1. coderabbitai commented on Nov 19, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #8573 - feat(service): wire the checked Windows stop into every stop path (#7771 slice 2) [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    bug
    cli
    platform
    on Nov 19, 2026
  3. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    Issue closed: insufficient detail

    Thanks for taking the time to submit this issue. It was closed automatically because the structured report is missing information needed to evaluate or reproduce it.

    • Version is missing.

    Please edit the issue to add:

    • Add your OpenCodex version so we can reproduce the environment.

    See the Contributing guide for details.

    Once the report passes the automated checks, it will be reopened automatically unless a maintainer has changed its state.

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

    bugcliplatform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions