fix: version 3.1.1 -- Actualizador no queda colgado al reiniciar el backend

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Milton Gonzalez
2026-10-23 14:25:49 -05:00
parent 4056c70d90
commit 72890e37d9
6 changed files with 24 additions and 9 deletions
@@ -18,6 +18,9 @@ const PHASE_KEYS = {
complete: 'updater_phase_verify',
};
// Avance por fase real del script (no por tiempo). El 100% solo llega al confirmar las versiones.
const PHASE_PCT = { backup: 10, source: 20, backend: 40, frontend: 65, publish: 85, restart: 90, complete: 95 };
export default function UpdaterPanel() {
const { t, openDialog } = useUi();
const { data: status, loading, error, reload } = useAsync(getUpdateStatus, []);
@@ -36,7 +39,9 @@ export default function UpdaterPanel() {
return () => { mountedRef.current = false; };
}, []);
// El estado del script confirma el final; ambas versiones comprueban lo que realmente se sirve.
// Termina cuando el backend YA reiniciado reporta la version nueva (runningVersion se lee al
// arrancar el proceso) y el frontend sirve la misma. No depende de la marca "done" del script:
// al reiniciar el backend, systemd puede matar al script (corre en el cgroup del backend).
async function pollUntilReady(targetVersion, startedAt) {
if (pollingRef.current) return;
pollingRef.current = true;
@@ -46,16 +51,16 @@ export default function UpdaterPanel() {
while (mountedRef.current && Date.now() - startedAt < POLL_TIMEOUT_MS) {
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
if (!mountedRef.current) return;
setProgressPct(Math.min(95, Math.round(((Date.now() - startedAt) / POLL_TIMEOUT_MS) * 100)));
try {
const progress = await getApplyProgress();
if (progress.targetVersion !== targetVersion) continue;
setPhase(progress.phase);
setProgressPct((pct) => Math.max(pct, PHASE_PCT[progress.phase] ?? pct));
if (progress.state === 'failed') {
setApplyError(t('updater_apply_failed'));
return;
}
if (progress.state === 'done' && progress.runningVersion === targetVersion) {
if (progress.runningVersion === targetVersion) {
const frontendVersion = await getFrontendVersion();
if (frontendVersion !== targetVersion) continue;
setProgressPct(100);