From e4896e5afe119be520884ea2909139e167cbf6b9 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Mon, 19 Oct 2026 16:30:31 -0700 Subject: [PATCH] fix(notebook): keep a woken background from checking one section over and over Background::wake set every section due "now", so a wake that came again before a round finished tied them all at the same moment, and the scheduler, which takes the first of equal dues, checked the first section again while the rest waited. Library::flush wakes every 50 ms until each closed section has synced, so on a loaded machine, where a check takes longer than that, it starved every section but the first and timed out: the mobile tests finishing_keeps_offline_copies_and_close_notebook_deletes_them and a_provider_that_lists_but_cannot_open_opens_from_the_offline_copies failed 34 and 6 times in 36 loaded runs of the suite (12 at once, three rounds). A wake now brings forward only sections not yet due, so those waiting keep their place: 0 and 0 in 36. Assisted-by: claude-opus-5.5 --- crates/notebook/src/background.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/notebook/src/background.rs b/crates/notebook/src/background.rs index e8fb6834151d73fd98f882b23f178063422f2a32..c8f780bc80176452387485de5abfda82ccb3117f 100644 --- a/crates/notebook/src/background.rs +++ b/crates/notebook/src/background.rs @@ -539,12 +539,14 @@ impl Background { .unwrap_or_default() } - /// Reads every section's stamp now, working offline included (Sync Now). + /// Reads every section's stamp now, working offline included (Sync Now). A section already + /// due keeps its place: waking again while a round runs would otherwise tie every section + /// at now, and the first would be checked over and over while the rest waited. pub fn wake(&self) { if let Ok(mut watched) = self.0.watched.lock() { let now = Instant::now(); for watch in &mut watched.sections { - watch.due = now; + watch.due = watch.due.min(now); watch.current = false; } } -- 2.54.1