fix(store): error instead of panic on invalid rid (#3157)

This commit is contained in:
Tony
2025-12-09 18:02:23 +08:00
committed by GitHub
parent 521cd8b372
commit eebfd2ed3e
2 changed files with 10 additions and 1 deletions
+4 -1
View File
@@ -197,7 +197,10 @@ impl<R: Runtime> StoreBuilder<R> {
let _ = self.app.resources_table().take::<Store<R>>(rid);
}
} else if let Some(rid) = stores.get(&self.path) {
return Ok((self.app.resources_table().get(*rid).unwrap(), *rid));
// The resource id we stored can be invalid due to
// the resource table getting modified by an external source
// (e.g. `App::cleanup_before_exit` > `manager.resources_table.clear()`)
return Ok((self.app.resources_table().get(*rid)?, *rid));
}
// if stores.contains_key(&self.path) {