     }
 }
 
-struct PackageIndexMetadataProvider: PackageMetadataProvider {
+struct PackageIndexMetadataProvider: PackageMetadataProvider, Closable {
+    typealias ProviderContainer = (provider: PackageMetadataProvider, managed: Bool)
+    
     let index: PackageIndex
-    let alternative: PackageMetadataProvider
+    let alternativeContainer: ProviderContainer
+    
+    var alternative: PackageMetadataProvider {
+        self.alternativeContainer.provider
+    }
 
     func get(
         identity: PackageIdentity,

        )
        let metadataProvider = PackageIndexMetadataProvider(
            index: index,
            alternative: GitHubPackageMetadataProvider(
                configuration: .init(authTokens: collectionsConfiguration.authTokens),
                observabilityScope: observabilityScope
            )
        )
        

            self.index.get(identity: identity, location: location, callback: callback)
        } else {
            self.alternative.get(identity: identity, location: location, callback: callback)
        }
    }
    
    func close() throws {
        guard self.alternativeContainer.managed else {
            return
        }
        if let alternative = self.alternative as? Closable {
            try alternative.close()
        }
    }
}
