Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

test(db): await deferred reclamation after cancelled reads

louisa4a14351d1a0
diff --git a/crates/screenpipe-db/src/storage/reader.rs b/crates/screenpipe-db/src/storage/reader.rs
index 9a8d7c83e..70603015f 100644
--- a/crates/screenpipe-db/src/storage/reader.rs
+++ b/crates/screenpipe-db/src/storage/reader.rs
@@ -623,7 +623,19 @@ mod tests {
db.execute_raw_sql_write("DELETE FROM frames WHERE id=1")
.await
.unwrap();
- assert_eq!(db.reclaim_frame_payloads().await.unwrap(), 1);
+ // Reclamation is nonblocking and can defer while SQLite finishes
+ // resetting a cancelled statement, even after the file pin drains.
+ tokio::time::timeout(std::time::Duration::from_secs(2), async {
+ loop {
+ match db.reclaim_frame_payloads().await.unwrap() {
+ 1 => break,
+ 0 => tokio::task::yield_now().await,
+ count => panic!("unexpected reclaimed file count: {count}"),
+ }
+ }
+ })
+ .await
+ .expect("cancelled read prevented file reclamation");
db.close().await;
}
}