Skip to content

[Bug]: ocx update --help performs the real npm self-update #168

Closed

Description

@0disoft

Summary

On a global npm installation, ocx update --help performs the real self-update instead of printing help and exiting without side effects.

This is especially disruptive when Codex Desktop is currently routed through the local opencodex proxy: the update restarts the proxy and drops the in-flight Responses stream.

Reproduction

Environment:

  • Windows 11
  • PowerShell 7.6.3
  • global npm installation
  • starting version: @bitkyc08/opencodex@2.7.23
  • target/latest version: 2.7.26
  • proxy running as the Task Scheduler service on 127.0.0.1:10100

Steps:

  1. Keep the opencodex service running.
  2. Route an active Codex Desktop thread through the proxy.
  3. Run:
ocx update --help

Expected behavior

Print the update subcommand help and exit successfully without checking, installing, stopping, or restarting anything.

Actual behavior

The npm self-update runs. In this reproduction it updated 2.7.23 -> 2.7.26, restarted the proxy, and the active Codex turn failed with:

stream disconnected before completion: error sending request for url (http://127.0.0.1:10100/v1/responses)

After reconnecting:

opencodex v2.7.26 (installed via npm, tag latest)
Already on the latest latest version (v2.7.26).

Root cause

The TypeScript CLI correctly handles subcommand help before dispatch:

https://github.com/lidge-jun/opencodex/blob/v2.7.26/src/cli/index.ts#L48-L55

However, the npm launcher intercepts every npm-installed update command before the Bun CLI receives --help:

https://github.com/lidge-jun/opencodex/blob/v2.7.26/bin/ocx.mjs#L225-L227

if (process.argv[2] === "update" && isNodeModulesInstall() && !isBunGlobalInstall()) {
  runNpmSelfUpdate();
}

That condition does not exclude --help, -h, or help.

Suggested fix

Before calling runNpmSelfUpdate(), detect help arguments and forward the command to the normal CLI help path. A regression test should verify that all of these are side-effect free:

ocx update --help
ocx update -h
ocx update help

This is related in spirit to the earlier subcommand-help safety work mentioned in #11/#14, but it is a separate npm-launcher bypass that remains present in v2.7.26.

Activity

  1. added a commit that references this issue on Jul 20, 2026
  2. lidge-jun commented on Jul 20, 2026

    @lidge-jun
    Owner

    재현 확인했고 dev에 수정 랜딩했습니다 (a4f06be).

    원인: 두 진입로 모두 --help를 검사하지 않고 곧바로 self-update를 실행:

    1. npm 글로벌 설치는 bin 런처(bin/ocx.mjs)가 Bun CLI보다 먼저 update를 가로채 실제 업데이트 실행 — 리포트하신 경로.
    2. Bun CLI(src/cli/index.ts)의 case "update"도 인자 검사 없이 runUpdate() 호출.

    수정: 양쪽 모두 ocx update [--help|-h|help]에서 usage만 출력하고 exit 0 (부작용 없음). 회귀 테스트 추가, 로컬 실기 검증 완료(두 진입로 모두 usage 출력 + exit 0).

    다음 릴리스에 포함됩니다. 제보 감사합니다 — 프록시가 라우팅 중인 스트림을 끊는 심각한 footgun이었습니다.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions