You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0be28c4
Browse filesBrowse the repository at this point in the historyBrowse files
fix(update): skip redundant GUI restart after npm self-update
npm ocx update already restarts the service; a second service install stopped the healthy proxy on 10100 and often failed elevation from the non-interactive worker.
@@ -404,25 +410,19 @@ function restartFailureHint(port: number): string {
404
410
+"reinstall with 'npm install -g --allow-scripts=bun @bitkyc08/opencodex'.";
405
411
}
406
412
413
+
typeAwaitHealthyResult=
414
+
|{ok: true}
415
+
|{ok: false;reason: "timeout"|"flapped"};
416
+
407
417
/**
408
-
* Confirm that the detached/service restart really came back and stayed up. The GUI worker
409
-
* used to mark success immediately after spawning the new process, which hid Windows cases
410
-
* where npm left the bundled Bun runtime half-updated and the restarted proxy died seconds
411
-
* later. A healthy /healthz must appear, then remain healthy for one short stability window.
418
+
* Wait for an identity-checked /healthz on the captured listen target, then require a short
419
+
* stability window. Soft: never marks the job failed (callers decide whether to fail or retry).
412
420
*/
413
-
asyncfunctionconfirmRestartedProxy(
421
+
asyncfunctionawaitRestartedProxyHealthy(
414
422
job: UpdateJobState,
415
423
captured: {port: number;hostname: string},
416
424
io: RestartIo={},
417
-
): Promise<boolean>{
418
-
/* [Decision Log]
419
-
- 목적과 의도: GUI update job이 detached restart 요청만 보고 성공 처리하지 않도록, 실제 프록시 복귀 여부를 확인한다.
420
-
- 기존 구현 및 제약 조건: update-job.json은 spawn/service reinstall 직후 `succeeded`로 끝났고, Windows npm/Bun 교체 실패처럼 몇 초 후 죽는 재시작을 잡지 못했다.
421
-
- 검토한 주요 대안: (1) 포트 점유만 확인 — 외부 프로세스/죽기 직전 프로세스를 성공으로 오인할 수 있다. (2) 무기한 /healthz 폴링 — UX가 느려지고 worker 종료 시점이 불명확하다. (3) 짧은 healthy 등장 + 안정성 창 확인 — 실제 복귀를 확인하면서도 대기 시간을 제한할 수 있다.
422
-
- 선택한 방식: identity-aware /healthz probe가 일정 시간 안에 나타나고, 추가 안정성 창 동안 유지되는지 확인한다.
423
-
- 다른 대안 대신 이 방식을 선택한 이유: GUI는 "업데이트가 설치됐지만 재시작은 실패"를 분리해 알려줘야 하며, 이 방식이 가장 적은 오탐으로 그 경계를 만든다.
424
-
- 장점, 단점 및 영향: 장점은 silent restart failure가 update-job 상태로 드러난다는 점이다. 단점은 성공 판정이 최대 30초 늦어질 수 있다는 점이며, 대신 실제 복귀를 더 정확히 반영한다.
error: `proxy restart became unhealthy on ${hostname}:${port}`,
447
-
},restartFailureHint(port));
448
-
returnfalse;
443
+
updateJob(job,{},`Proxy became unhealthy on ${hostname}:${port} during the stability window.`);
444
+
return{ok: false,reason: "flapped"};
449
445
}
450
446
awaitsleep(500);
451
447
}
452
448
updateJob(job,{},`Proxy stayed healthy for ${Math.trunc(RESTART_STABILITY_WINDOW_MS/1000)}s after restart.`);
453
-
returntrue;
449
+
return{ok: true};
454
450
}
455
451
awaitsleep(250);
456
452
}
457
453
454
+
return{ok: false,reason: "timeout"};
455
+
}
456
+
457
+
/**
458
+
* Confirm that the detached/service restart really came back and stayed up. The GUI worker
459
+
* used to mark success immediately after spawning the new process, which hid Windows cases
460
+
* where npm left the bundled Bun runtime half-updated and the restarted proxy died seconds
461
+
* later. A healthy /healthz must appear, then remain healthy for one short stability window.
462
+
*/
463
+
asyncfunctionconfirmRestartedProxy(
464
+
job: UpdateJobState,
465
+
captured: {port: number;hostname: string},
466
+
io: RestartIo={},
467
+
): Promise<boolean>{
468
+
/* [Decision Log]
469
+
- 목적과 의도: GUI update job이 detached restart 요청만 보고 성공 처리하지 않도록, 실제 프록시 복귀 여부를 확인한다.
470
+
- 기존 구현 및 제약 조건: update-job.json은 spawn/service reinstall 직후 `succeeded`로 끝났고, Windows npm/Bun 교체 실패처럼 몇 초 후 죽는 재시작을 잡지 못했다.
471
+
- 검토한 주요 대안: (1) 포트 점유만 확인 — 외부 프로세스/죽기 직전 프로세스를 성공으로 오인할 수 있다. (2) 무기한 /healthz 폴링 — UX가 느려지고 worker 종료 시점이 불명확하다. (3) 짧은 healthy 등장 + 안정성 창 확인 — 실제 복귀를 확인하면서도 대기 시간을 제한할 수 있다.
472
+
- 선택한 방식: identity-aware /healthz probe가 일정 시간 안에 나타나고, 추가 안정성 창 동안 유지되는지 확인한다.
473
+
- 다른 대안 대신 이 방식을 선택한 이유: GUI는 "업데이트가 설치됐지만 재시작은 실패"를 분리해 알려줘야 하며, 이 방식이 가장 적은 오탐으로 그 경계를 만든다.
474
+
- 장점, 단점 및 영향: 장점은 silent restart failure가 update-job 상태로 드러난다는 점이다. 단점은 성공 판정이 최대 30초 늦어질 수 있다는 점이며, 대신 실제 복귀를 더 정확히 반영한다.
0 commit comments