From 75c46dad7be5c0e9f3e7eb556fd3cbeae0bb65b8 Mon Sep 17 00:00:00 2001 From: austin62jake Date: Mon, 2 Nov 2026 00:09:03 +0000 Subject: [PATCH] Tests: the autosave scenario crashes once its autosave has landed (#10690) (#10694) * Tests: the autosave scenario crashes once its autosave has landed (#10690) Co-Authored-By: Claude Opus 5.5 * Tests: the autosave scenario crashes once its autosave has landed (#10690) s25_autosave_recovery 'crashed' right after the extrude; under load the autosave of it, written on a worker thread, had not landed, so the next launch recovered the earlier autosave without the body (step 16). The harness's crash restart now runs frames, bounded, until the active autosave has caught up (Autosaver::caught_up: no write running and the last autosave holds the design as it is). The app's own ticks still do the writing, so an autosave that stopped writing still fails the test. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude --- crates/engine/src/recovery.rs | 8 ++++++++ crates/ui-egui/src/scenario.rs | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/crates/engine/src/recovery.rs b/crates/engine/src/recovery.rs index 59b349935..e05c079fb 100644 --- a/crates/engine/src/recovery.rs +++ b/crates/engine/src/recovery.rs @@ -283,6 +283,14 @@ impl Autosaver { Ok(true) } + /// Whether the last autosave holds `s` as it is now, with no write still running: what a + /// crash now would leave for the next launch to offer. A finished write counts once a + /// [`Self::tick`] has taken its outcome. + pub fn caught_up(&self, s: &Session) -> bool { + self.writing.is_none() + && self.last.as_ref().is_some_and(|(doc, visibility)| (Arc::ptr_eq(doc, &s.doc) || **doc == *s.doc) && *visibility == s.visibility) + } + /// Autosave when the interval has passed, or right away after a big operation. The design /// is written on a worker thread; true when this call started a write. pub fn tick(&mut self, s: &Session, big: bool) -> Result { diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs index e8c9c333a..277466f1c 100644 --- a/crates/ui-egui/src/scenario.rs +++ b/crates/ui-egui/src/scenario.rs @@ -595,6 +595,20 @@ impl Harness { } else if let Some(how) = s.get("restart").and_then(Value::as_str) { // "crash": the app dies (its autosave lock goes with it, the entry stays); // "close": it closes normally. Then a new app starts on the same folders. + if how == "crash" { + // The work so far is autosaved before the crash: the write runs on a worker + // thread, which a loaded machine had not finished (#10690). The autosave's + // own ticks write it; a bounded wait, so an autosave that stopped writing + // still fails the recovery that follows. + for _ in 0..600 { + let caught_up = self.app.autosave.as_ref().and_then(|a| a.active.as_ref()).is_none_or(|a| a.caught_up(&self.app.session)); + if caught_up { + break; + } + std::thread::sleep(std::time::Duration::from_millis(5)); + self.frames(1); + } + } let mut old = std::mem::replace(&mut self.app, SolveApp::new(Session::default(), Services::default())); if how == "close" { crate::recovery_ui::close(&mut old);