Repository navigation
Studio: stop showing "Update failed" when the window is reloaded during an update - #11226
Conversation
|
@codex review |
Reproduction on CI, and two gaps this closesA/B on a real runner (ubuntu-22.04, identical workflow and probe on both branches; only the product code differs). The test holds the managed runtime gate the way an install or update does, then runs the preflight probe:
Before / afterSame scene on both sides: the desktop startup screen with the preflight result each side's Rust actually produces for a reload during an update.
Two gaps found while verifying, now fixed
Also: the wait is now bounded (5 minutes) so a gate held by a terminal The frontend test that shipped with the first commit asserted only that two substrings appeared in the hook source in a given order — it passed with the busy branch removed. Replaced with 512 Rust tests and 7828 frontend tests pass. |
… and bound only an outside gate
|
Pushed fe1071d on top:
|
|
Codex review converged on the staging mirror (head Since the last update, two more fixes from that review: the own install/update check now runs on both sides of the preflight probe (an install finishing mid-probe no longer leaks a half-written reading), and |
|
Codex review converged again on the new head |
|
Confirmed this still hits main, where preflight.rs:44 and :105 gate on is_context_reason so a busy runtime gate comes back as cli_unusable and start_managed_repair then refuses at commands.rs:952. The wait-and-repoll route looks right; will get this reviewed. |
unslothai#11226 landed the same single-flight while this was in review: UpdateProcess.repair_in_flight, a RepairInFlight guard with the same RAII shape and the same poisoned-lock release, claimed at the top of start_managed_repair. Rebasing onto main left two flags for one invariant, so this drops the copy in InstallProcess and keeps main's. What main does not have, and this keeps: start_install and start_backend_update refuse while a repair is in flight. They now ask update::is_repair_running, which is the flag main already keeps, rather than a second one. start_install gains the UpdateState parameter that needs; Tauri injects state by type, so no caller changes. start_managed_repair keeps its original "installation is in progress" refusal ahead of the claim, which is where main has it. The two unit tests that covered the removed flag are dropped: update.rs already tests the guard it kept, including the poisoned-lock release, and duplicating that against a deleted type is not coverage. The frontend single-flight and its test are untouched.
…#11249) * Desktop: run one managed repair at a time start_managed_repair guarded itself with the install and update child handles, which are empty while it stops the backend and between the update child and the installer. Five Retry clicks two seconds apart after a backend crash each passed the guards, each ran their own `studio update`, and then raced for the bundled installer: one won and the other four surfaced "Installation is already running." over its progress. The install state now carries a repair_in_flight flag taken at the top of the command and released by a guard on every exit; update and install refuse while it is set. The frontend stops the fan-out at its source: one preflight and one repair in flight at a time. * Keep one repair flag, the one already on main #11226 landed the same single-flight while this was in review: UpdateProcess.repair_in_flight, a RepairInFlight guard with the same RAII shape and the same poisoned-lock release, claimed at the top of start_managed_repair. Rebasing onto main left two flags for one invariant, so this drops the copy in InstallProcess and keeps main's. What main does not have, and this keeps: start_install and start_backend_update refuse while a repair is in flight. They now ask update::is_repair_running, which is the flag main already keeps, rather than a second one. start_install gains the UpdateState parameter that needs; Tauri injects state by type, so no caller changes. start_managed_repair keeps its original "installation is in progress" refusal ahead of the claim, which is where main has it. The two unit tests that covered the removed flag are dropped: update.rs already tests the guard it kept, including the poisoned-lock release, and duplicating that against a deleted type is not coverage. The frontend single-flight and its test are untouched. * Hold the preflight flag over the probe, not over what the probe starts The guard spanned the whole of checkInstallAndStart, including the managed_ready arm's await startManagedServer(), which parks in waitForManagedServerPort's 500 ms poll. The server-start-timeout handler clears startingRef and shows Retry from inside that wait, so a click arriving before the poll next wakes cleared the error and then returned on the flag, leaving the screen in error with nothing running until the user clicked again. Released as soon as desktop_preflight returns. The dispositions it leads to are re-entrant on their own account: startManagedServer takes startingRef, startRepair takes repairInFlightRef. What the flag exists to stop, five Retry clicks fanning out into five preflights and five repairs, is unchanged. The test now pins the release point between the probe and the switch, and that no long await runs while the flag is held. It fails on the previous shape. * Tighten the comments this change added * Give the managed-environment harness the flag the hook now reads managed-environment-wait.test.ts evals checkInstallAndStart's body in a scope it builds by hand, so the preflight guard this PR adds resolved to nothing and all six cases died with ReferenceError: preflightInFlightRef is not defined. Landed on main after this branch was cut, which is why the branch was green when it was opened. * Release the preflight flag only while this call still owns it Releasing early at the probe left the finally clearing the flag unconditionally, and by then it may belong to someone else: A releases, A is still awaiting startManagedServer, Retry starts B which arms the flag, A finishes and its finally clears B's, and a third Retry runs a preflight concurrently with B. That is the fan-out the guard exists to stop. releasePreflight() is a no-op once this call has handed the flag on, and both the early release and the finally go through it. The test pins that shape and fails on an unconditional clear. * Release the repair flag when the repair ends, not when the server starts Same window as the preflight one, one flag along. runRepair awaits startManagedServer after the native repair returns, and repairInFlightRef covered that too: server-start-timeout offers Retry from inside the port poll, preflight comes back managed_stale, and the startRepair it leads to is dropped on the flag after Retry has already cleared the error. The flag is released the moment start_managed_repair returns, through the same ownership-aware release as the preflight guard, so a call that has handed it on cannot clear a later one's. What follows the native call is an ordinary server start, which startingRef already guards. * Shorten the comments this change added --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Daniel Han <[email protected]>
…ng an update (unslothai#11226) * Desktop: wait out a busy managed environment instead of repairing it * Stub the environment wait in the retry test * Desktop: treat our own install as a busy environment, and bound the wait * fix(desktop): wait out this app's own install on every managed probe, and bound only an outside gate * fix(desktop): check our own install on both sides of the preflight probe * fix(desktop): hold a repair as running across its update and installer phases * fix(desktop): keep the probe spawns inside their own runtime gate call --------- Co-authored-by: Lyxot <[email protected]>
…unslothai#11249) * Desktop: run one managed repair at a time start_managed_repair guarded itself with the install and update child handles, which are empty while it stops the backend and between the update child and the installer. Five Retry clicks two seconds apart after a backend crash each passed the guards, each ran their own `studio update`, and then raced for the bundled installer: one won and the other four surfaced "Installation is already running." over its progress. The install state now carries a repair_in_flight flag taken at the top of the command and released by a guard on every exit; update and install refuse while it is set. The frontend stops the fan-out at its source: one preflight and one repair in flight at a time. * Keep one repair flag, the one already on main unslothai#11226 landed the same single-flight while this was in review: UpdateProcess.repair_in_flight, a RepairInFlight guard with the same RAII shape and the same poisoned-lock release, claimed at the top of start_managed_repair. Rebasing onto main left two flags for one invariant, so this drops the copy in InstallProcess and keeps main's. What main does not have, and this keeps: start_install and start_backend_update refuse while a repair is in flight. They now ask update::is_repair_running, which is the flag main already keeps, rather than a second one. start_install gains the UpdateState parameter that needs; Tauri injects state by type, so no caller changes. start_managed_repair keeps its original "installation is in progress" refusal ahead of the claim, which is where main has it. The two unit tests that covered the removed flag are dropped: update.rs already tests the guard it kept, including the poisoned-lock release, and duplicating that against a deleted type is not coverage. The frontend single-flight and its test are untouched. * Hold the preflight flag over the probe, not over what the probe starts The guard spanned the whole of checkInstallAndStart, including the managed_ready arm's await startManagedServer(), which parks in waitForManagedServerPort's 500 ms poll. The server-start-timeout handler clears startingRef and shows Retry from inside that wait, so a click arriving before the poll next wakes cleared the error and then returned on the flag, leaving the screen in error with nothing running until the user clicked again. Released as soon as desktop_preflight returns. The dispositions it leads to are re-entrant on their own account: startManagedServer takes startingRef, startRepair takes repairInFlightRef. What the flag exists to stop, five Retry clicks fanning out into five preflights and five repairs, is unchanged. The test now pins the release point between the probe and the switch, and that no long await runs while the flag is held. It fails on the previous shape. * Tighten the comments this change added * Give the managed-environment harness the flag the hook now reads managed-environment-wait.test.ts evals checkInstallAndStart's body in a scope it builds by hand, so the preflight guard this PR adds resolved to nothing and all six cases died with ReferenceError: preflightInFlightRef is not defined. Landed on main after this branch was cut, which is why the branch was green when it was opened. * Release the preflight flag only while this call still owns it Releasing early at the probe left the finally clearing the flag unconditionally, and by then it may belong to someone else: A releases, A is still awaiting startManagedServer, Retry starts B which arms the flag, A finishes and its finally clears B's, and a third Retry runs a preflight concurrently with B. That is the fan-out the guard exists to stop. releasePreflight() is a no-op once this call has handed the flag on, and both the early release and the finally go through it. The test pins that shape and fails on an unconditional clear. * Release the repair flag when the repair ends, not when the server starts Same window as the preflight one, one flag along. runRepair awaits startManagedServer after the native repair returns, and repairInFlightRef covered that too: server-start-timeout offers Retry from inside the port poll, preflight comes back managed_stale, and the startRepair it leads to is dropped on the flag after Retry has already cleared the error. The flag is released the moment start_managed_repair returns, through the same ownership-aware release as the preflight guard, so a call that has handed it on cannot clear a later one's. What follows the native call is an ordinary server start, which startingRef already guards. * Shorten the comments this change added --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Daniel Han <[email protected]>

Reloading the desktop window during an update shows "Update failed: Repair is already running." even though the update is still running fine.
The reload makes the app check the install again. The update has it locked, so the check cannot run, and the app wrongly treats the install as broken and tries to repair it.
Now the app waits instead. It shows "Finishing update..." and checks again every 5 seconds, then starts by itself once the update is done. The refusal message also now says "An update or repair is already running."
Tested by holding the install lock and opening the app. Before: reported as broken. After: waits, then continues when the lock is released.