Repository navigation
Description
Client or integration
- OpenCodex dashboard (GUI 업데이트) / CLI (
ocx system update run --yes)
Area
- Service lifecycle (업데이트 잡 상태 관리)
Summary
업데이트 워커 프로세스가 비정상 종료되면 ~/.opencodex/update-job.json의 상태가 running 또는 restarting으로 영구 고착(stuck)되어, 이후 GUI 업데이트 버튼이나 ocx system update run --yes를 누를 때마다 무조건 An update job is already running (update_already_running, HTTP 409)만 반환하고 업데이트가 진행되지 않습니다.
코드를 추적한 결과 상태 판정이 신뢰할 수 없게 설계되어 있어 고착 상태에서 자동으로 회복할 수단이 없습니다.
근본 원인 (검증한 코드 위치):
-
워커 PID가 디스크 파일에 기록되지 않음
src/update/job.ts:255의writeJob(job)이spawn이전에 호출되고,src/update/job.ts:264의child.pid는 HTTP 응답 객체에만 추가될 뿐update-job.json에는 저장되지 않습니다. 결과적으로 "이전 job의 워커가 아직 살아있는가?"를 검증할 방법이 코드상 존재하지 않습니다. -
stale/OBAN(오래된 잡) 판정이 전혀 없음
readUpdateJob(src/update/job.ts:121-130)은 JSON 파일만 읽고updatedAt의 경과 시간을 전혀 검사하지 않습니다. 업데이트 최대 시간은UPDATE_TIMEOUT_MS=180s(src/update/job.ts:27) + 재시작 안정성 창 ~15s인데, 그보다 훨씬 오래된running상태도 신선한 것과 동일하게 취급합니다. -
취소/리셋 명령·엔드포인트 부재
ocx system update는check/run/status만 있고(src/cli/system-command.ts:68-93), 서버측/api/update/run(src/server/management/config-routes.ts:244-262)에도 stuck job을 해제할 수단이 없습니다. -
guard 자체
src/update/job.ts:228-232의startUpdateJob()guard는 단순히 상태 값만 보고 무조건 reject합니다.
이 동작을 명시하는 테스트도 tests/update-job.test.ts:683-705("a running job prevents a second update job")에 있어, 의도된(고착 가능성을 각오했던) 동작입니다.
기대 동작: 워커가 죽었거나 잡이 충분히 오래되었으면 stale로 판정해 자동으로 해제하고 새 업데이트를 허용해야 합니다.
Reproduction
ocx start --port 10100(또는 서비스 설치 상태)에서 프로키시를 띄운다.ocx system update run --yes --channel latest를 실행해 GUI/CLI 업데이트 잡을 시작한다.- 업데이트 워커가 비정상 종료되는 상황을 만든다 — 예: 워커 프로세스를 강제 kill(
kill -9 <worker pid>), 시스템 강제 재부팅, 정전, 또는 워커 내부에서 throw되어 잡 상태가 갱신되기 전에 종료. - 잡이 종료된 후 다시
ocx system update run --yes를 실행한다. - 관찰:
An update job is already running(409)만 반환되고 업데이트가 영원히 진행되지 않음.
워크어라운드(즉시 회피): rm -f ~/.opencodex/update-job.json (또는 $OPENCODEX_HOME/update-job.json)을 실행하면 다음 업데이트 시도가 정상 작동합니다.
Version
@bitkyc08/opencodexv2.7.42- commit:
7cb15bff4efd7beafc49d0a125432230c6ec9461(2026-07-28,mainHEAD 기준)
Operating system
- Ubuntu 24.04 (재현 환경). 단, 코드상 플랫폼 무관하며 Windows/macOS에서도 동일하게 발생합니다 (
src/update/job.ts시작 경로는process.platform분기 없이 동일 로직).
Provider and model
- 해당 없음 (업데이트/서비스 수명주기 문제)
Logs or error output
HTTP 409 {"error":"An update job is already running","code":"update_already_running"}
영향받는 코드 (합厌):
- src/update/job.ts:228 — startUpdateJob guard (PID/신선도 검증 없음)
- src/update/job.ts:121 — readUpdateJob (updatedAt 미검사)
- src/update/job.ts:255-264 — writeJob이 spawn 전 호출, child.pid 미기록
- src/cli/system-command.ts:68 — update 명령에 취소/리셋 부재
- src/server/management/config-routes.ts:244 — /api/update/run에 stale 해제 부재
- tests/update-job.test.ts:683 — 의도된 고착 동작을 명시하는 테스트
제안하는 수정 방향
startUpdateJob()의 guard를 "살아있음 + 신선도" 기반으로 변경:
- spawn 직후 워커 PID를 파일에 write (
src/update/job.ts:263근처writeJob({ ...job, pid: child.pid })). - running/restarting 잡을 reject 하기 전, 기존 잡에 대해:
isProcessAlive(job.pid)(src/lib/process-control.ts:4에 이미 존재)로 워커가 죽었으면 stale로 판정.updatedAt경과가 임계치(예: ~5분)를 초과하면 stale로 판정.- stale이면 해당 잡을
failed로 갱신하고 새 잡을 허용(또는 자동으로 무시하고 진행).
- (선택) 서버측
/api/update/run또는ocx system update cancel로 명시적 리셋 옵션 추가.
위 (1)과 (2)를 같이 넣는 것이 가장 신뢰도가 높습니다 — PID가 기록되어야 stale 판정이 안전하고, PID만으로는 워커가 detached/세션 분리된 경우 검증이 불완전할 수 있어 신선도 타임아웃이 보완 역할을 합니다.
Checks
- 기존 이슈와 문서를 검색했습니다 ([Bug]:
ocx update --helpperforms the real npm self-update #168ocx update --help관련, [Feature]: Windows에서 창 없는 백그라운드 서비스 실행 모드 #166 백그라운드 서비스 모드는 동일 문제가 아님). - 비밀, 토큰, 계정 정보, 요청 자격증명, 개인정보를 제거했습니다.
Translated Message
Original language: Korean
Client or integration
- OpenCodex dashboard (GUI update) / CLI (
ocx system update run --yes)
Area
- Service lifecycle (update job status management)
Summary
When the update worker process crashes abnormally, the state of ~/.opencodex/update-job.json becomes permanently stuck as running or restarting, causing an HTTP An update job is already running (update_already_running, HTTP 409) response every time the GUI update button or ocx system update run --yes is pressed, and preventing updates from proceeding.
Upon tracking the code, it was found that the state determination is poorly designed, with no means for automatic recovery from a stuck state.
Root causes (verified code locations):
-
Worker PID not recorded in disk file
src/update/job.ts:255'swriteJob(job)is called beforespawn, andsrc/update/job.ts:264'schild.pidis only added to the HTTP response object and not saved inupdate-job.json. As a result, there is no way in the code to verify "Is the previous job's worker still alive?" -
No stale/OBAN (old job) determination
readUpdateJob(src/update/job.ts:121-130) only reads the JSON file and does not check the elapsed time ofupdatedAt. The maximum update time isUPDATE_TIMEOUT_MS=180s(src/update/job.ts:27) + restart stability window ~15s, butrunningstates older than that are treated the same as fresh ones. -
Lack of cancel/reset commands/endpoints
ocx system updateonly hascheck/run/status(src/cli/system-command.ts:68-93), and the server-side/api/update/run(src/server/management/config-routes.ts:244-262) does not provide a way to release stuck jobs. -
Guard itself
src/update/job.ts:228-232'sstartUpdateJob()guard simply checks the state value and always rejects.
There are also tests specifying this behavior at tests/update-job.test.ts:683-705 ("a running job prevents a second update job"), indicating it is an intended behavior (prepared for potential stuck).
Expected behavior: If the worker is dead or the job is old enough, it should be determined stale and automatically released to allow new updates.
Reproduction
- Start the proxy in
ocx start --port 10100(or service installation state). - Execute
ocx system update run --yes --channel latestto start a GUI/CLI update job. - Create a situation where the update worker crashes abnormally — e.g., forcibly kill the worker process (
kill -9 <worker pid>), force system reboot, power outage, or throw from within the worker before job state updates. - After the job has terminated, execute
ocx system update run --yesagain. - Observe: Only
An update job is already running(409) is returned, and the update never proceeds.
Workaround (immediate avoidance): Executing rm -f ~/.opencodex/update-job.json (or $OPENCODEX_HOME/update-job.json) will allow the next update attempt to work normally.
Version
@bitkyc08/opencodexv2.7.42- commit:
7cb15bff4efd7beafc49d0a125432230c6ec9461(as of 2026-07-28,mainHEAD)
Operating system
- Ubuntu 24.04 (reproduction environment). However, platform independent in the code, it occurs the same on Windows/macOS (
src/update/job.tsstarting path has the same logic withoutprocess.platformbranches).
Provider and model
- Not applicable (update/service lifecycle issue)
Logs or error output
HTTP 409 {"error":"An update job is already running","code":"update_already_running"}
Affected code (incidental):
- src/update/job.ts:228 — startUpdateJob guard (no PID/freshness validation)
- src/update/job.ts:121 — readUpdateJob (no
updatedAtcheck) - src/update/job.ts:255-264 — writeJob called before spawn, child.pid not recorded
- src/cli/system-command.ts:68 — lack of cancel/reset in update command
- src/server/management/config-routes.ts:244 — absence of stale release in /api/update/run
- tests/update-job.test.ts:683 — test specifying intended stuck behavior
Suggested modification direction
Change the guard of startUpdateJob() to be based on "alive + freshness":
- Write the worker PID to the file immediately after spawn (
writeJob({ ...job, pid: child.pid })nearsrc/update/job.ts:263). - Before rejecting running/restarting jobs, for the existing job:
- Determine it stale if the worker is dead (
isProcessAlive(job.pid)already exists insrc/lib/process-control.ts:4). - Determine it stale if the
updatedAtelapsed time exceeds a threshold (e.g., ~5 minutes). - If stale, update the job to
failedand allow a new job (or ignore and proceed automatically).
- Determine it stale if the worker is dead (
- (Optional) Add an explicit reset option on the server-side
/api/update/runorocx system update cancel.
Including both (1) and (2) together provides the highest reliability — recording the PID is necessary for safe stale determination, and relying solely on the PID may lead to incomplete validation when the worker is detached/session separated, making freshness timeout a complementary role.
Activity
[-][Bug] 업데이트 워커 비정상 종료 시 update-job.json 영구 고착으로 이후 모든 업데이트가 'already running' 차단[/-][+][Bug] Permanent Stuck of update-job.json with 'already running' Block on Subsequent Updates when Update Worker Crashes[/+]github-actions commentedon Jul 28, 2026
Automated translation bookkeeping — detected language: English.
Ingwannu commentedon Jul 28, 2026
Confirmed on the current
devbranch.The active job state is persisted before the detached worker is spawned, but the returned child PID is never written back to
update-job.json. The existing guard then treats everyrunning/restartingrecord as live indefinitely.I am going to:
Ingwannu commentedon Jul 28, 2026
Fixed on
devin commit7710185c.The dashboard now persists the detached update worker PID, refuses a second update while that PID is alive, recovers immediately when the worker PID is dead, and recovers legacy no-PID active records after a conservative ten-minute window. Synchronous/asynchronous worker startup failures are also persisted as failed jobs instead of leaving an active record behind.
Regression coverage includes live/dead PID behavior, legacy stale-window behavior, replacement PID persistence, and spawn failure state. The full pre-push suite passed: 5,700 tests, TypeScript typecheck, GUI lint, and privacy scan.
This will be included in the next release cut from
dev.