fix: watcher startup grace period, defensive runtime drop on reload

This commit is contained in:
2026-03-26 17:59:32 +01:00
parent ab2d3cfe55
commit 38dda8c44c
2 changed files with 13 additions and 2 deletions

View File

@@ -69,9 +69,17 @@ fn watch_loop(
info!("Watching {} for plugin changes", plugins_dir.display());
// Skip events during initial startup grace period (watcher setup triggers events)
let startup = std::time::Instant::now();
let grace_period = Duration::from_secs(2);
loop {
match rx.recv() {
Ok(Ok(events)) => {
if startup.elapsed() < grace_period {
continue;
}
let has_relevant_change = events.iter().any(|e| {
matches!(
e.kind,

View File

@@ -292,8 +292,11 @@ impl ProviderManager {
!self.runtime_type_ids.contains(&type_str)
});
// Drop old runtimes
self.runtimes.clear();
// Drop old runtimes (catch panics from runtime cleanup)
let old_runtimes = std::mem::take(&mut self.runtimes);
drop(std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
drop(old_runtimes);
})));
self.runtime_type_ids.clear();
let owlry_version = env!("CARGO_PKG_VERSION");