mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(createVectorStoreNode): Prevent connection leaks in PGVectorStore pool
This commit is contained in:
parent
11e8520b70
commit
2c648ff82d
|
@ -4,6 +4,7 @@ import type { Document } from '@langchain/core/documents';
|
||||||
import type { Embeddings } from '@langchain/core/embeddings';
|
import type { Embeddings } from '@langchain/core/embeddings';
|
||||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||||
|
import { PGVectorStore } from '@langchain/community/vectorstores/pgvector';
|
||||||
import type {
|
import type {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
INodeCredentialDescription,
|
INodeCredentialDescription,
|
||||||
|
@ -395,7 +396,14 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
|
|
||||||
if (mode === 'retrieve') {
|
if (mode === 'retrieve') {
|
||||||
const vectorStore = await args.getVectorStoreClient(this, filter, embeddings, itemIndex);
|
const vectorStore = await args.getVectorStoreClient(this, filter, embeddings, itemIndex);
|
||||||
|
|
||||||
|
async function closeFunction() {
|
||||||
|
const pgVectorStore = vectorStore as PGVectorStore;
|
||||||
|
void pgVectorStore?.client?.release();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
closeFunction,
|
||||||
response: logWrapper(vectorStore, this),
|
response: logWrapper(vectorStore, this),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue