Skip to content

Commit 2b32cad

Browse files
authored
Fix extension manager resource deadlock (#5066)
Signed-off-by: alexyao2015 <alexyao2015@users.noreply.github.com> Co-authored-by: alexyao2019@gmail.com <alexyao2015@users.noreply.github.com>
1 parent fb6477a commit 2b32cad

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

crates/goose/src/agents/extension_manager.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,13 @@ impl ExtensionManager {
705705
// Loop through each extension and try to read the resource, don't raise an error if the resource is not found
706706
// TODO: do we want to find if a provided uri is in multiple extensions?
707707
// currently it will return the first match and skip any others
708-
for extension_name in self.extensions.lock().await.keys() {
708+
709+
// Collect extension names first to avoid holding the lock during iteration
710+
let extension_names: Vec<String> = self.extensions.lock().await.keys().cloned().collect();
711+
712+
for extension_name in extension_names {
709713
let result = self
710-
.read_resource_from_extension(uri, extension_name, cancellation_token.clone())
714+
.read_resource_from_extension(uri, &extension_name, cancellation_token.clone())
711715
.await;
712716
match result {
713717
Ok(result) => return Ok(result),

0 commit comments

Comments
 (0)