Sweep orphaned response bodies at browser startup (#576)

This commit is contained in:
Gregory Schier
2026-08-17 10:38:52 -07:00
committed by GitHub
parent b89c448345
commit 7ca772347f
15 changed files with 274 additions and 65 deletions
+8
View File
@@ -43,6 +43,10 @@ struct Host {
events: mpsc::Receiver<ModelPayload>,
}
fn lifecycle_host() -> yaak_lifecycle::Host {
yaak_lifecycle::Host::owner()
}
thread_local! {
static HOST: RefCell<Option<Host>> = const { RefCell::new(None) };
}
@@ -91,6 +95,10 @@ pub async fn boot() -> Result<()> {
let (queries, blobs, events) =
yaak_models::init_standalone(DB_NAME, BLOB_DB_NAME).map_err(js_error)?;
if let Err(e) = yaak_lifecycle::on_launch(&lifecycle_host(), &queries.connect(), &blobs) {
web_sys::console::warn_2(&"on_launch hook failed".into(), &js_error(e));
}
HOST.with(|h| *h.borrow_mut() = Some(Host { queries, blobs, events }));
Ok(())
}