@@ -40,12 +40,14 @@ export class MilvusVectorDatabase implements VectorDatabase {
4040 private async initializeClient ( address : string ) : Promise < void > {
4141 const milvusConfig = this . config as MilvusConfig ;
4242 console . log ( '🔌 Connecting to vector database at: ' , address ) ;
43+ const timeoutMs = Number ( process . env . MILVUS_TIMEOUT_MS ) || 60000 ;
4344 this . client = new MilvusClient ( {
4445 address : address ,
4546 username : milvusConfig . username ,
4647 password : milvusConfig . password ,
4748 token : milvusConfig . token ,
4849 ssl : milvusConfig . ssl || false ,
50+ timeout : timeoutMs ,
4951 } ) ;
5052 }
5153
@@ -742,42 +744,15 @@ export class MilvusVectorDatabase implements VectorDatabase {
742744 throw new Error ( 'MilvusClient is not initialized. Call ensureInitialized() first.' ) ;
743745 }
744746
745- const collectionName = `dummy_collection_${ Date . now ( ) } ` ;
746- const createCollectionParams = {
747- collection_name : collectionName ,
748- description : 'Test collection for limit check' ,
749- fields : [
750- {
751- name : 'id' ,
752- data_type : DataType . VarChar ,
753- max_length : 512 ,
754- is_primary_key : true ,
755- } ,
756- {
757- name : 'vector' ,
758- data_type : DataType . FloatVector ,
759- dim : 128 ,
760- }
761- ]
762- } ;
763-
764747 try {
765- await this . client . createCollection ( createCollectionParams ) ;
766- // Immediately drop the collection after successful creation
767- if ( await this . client . hasCollection ( { collection_name : collectionName } ) ) {
768- await this . client . dropCollection ( {
769- collection_name : collectionName ,
770- } ) ;
771- }
772- return true ;
748+ const response = await this . client . listCollections ( ) ;
749+ const maxCollections = Number ( process . env . MILVUS_MAX_COLLECTIONS ) || 4 ;
750+ return response . data . length < maxCollections ;
773751 } catch ( error : any ) {
774- // Check if the error message contains the collection limit exceeded pattern
775752 const errorMessage = error . message || error . toString ( ) || '' ;
776753 if ( / e x c e e d e d t h e l i m i t n u m b e r o f c o l l e c t i o n s / i. test ( errorMessage ) ) {
777- // Return false for collection limit exceeded
778754 return false ;
779755 }
780- // Re-throw other errors as-is
781756 throw error ;
782757 }
783758 }
0 commit comments