Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: Weaviate was not closed properly (#29301)

wangxiaoleica61bb5de0c1
diff --git a/api/core/rag/datasource/vdb/weaviate/weaviate_vector.py b/api/core/rag/datasource/vdb/weaviate/weaviate_vector.py
index 2c7bc592c09..84d1e26b344 100644
--- a/api/core/rag/datasource/vdb/weaviate/weaviate_vector.py
+++ b/api/core/rag/datasource/vdb/weaviate/weaviate_vector.py
@@ -79,6 +79,18 @@ class WeaviateVector(BaseVector):
self._client = self._init_client(config)
self._attributes = attributes
+ def __del__(self):
+ """
+ Destructor to properly close the Weaviate client connection.
+ Prevents connection leaks and resource warnings.
+ """
+ if hasattr(self, "_client") and self._client is not None:
+ try:
+ self._client.close()
+ except Exception as e:
+ # Ignore errors during cleanup as object is being destroyed
+ logger.warning("Error closing Weaviate client %s", e, exc_info=True)
+
def _init_client(self, config: WeaviateConfig) -> weaviate.WeaviateClient:
"""
Initializes and returns a connected Weaviate client.