Skip to content

Commit 3df8e9c

Browse files
Merge branch 'fix/grpc-timeout-deadline-exceeded' into fix/extend-default-extensions
2 parents 9564e4a + c739ed2 commit 3df8e9c

1 file changed

Lines changed: 5 additions & 30 deletions

File tree

packages/core/src/vectordb/milvus-vectordb.ts

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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 (/exceeded the limit number of collections/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

Comments
 (0)