Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Pg-promise de-initialization fix #7417

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/CrateDb/CrateDb.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,15 @@ export class CrateDb implements INodeType {
returnItems = this.helpers.returnJsonArray(getItemsCopy(items, columns));
}
} else {
pgp.end();
await db.$pool.end();
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
);
}

// Close the connection
pgp.end();
// shuts down the connection pool associated with the db object to allow the process to finish
await db.$pool.end();

return [returnItems];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export class MicrosoftSql implements INodeType {
}
}

// Close the connection
// shuts down the connection pool associated with the db object to allow the process to finish
await pool.close();

const itemData = generatePairedItemData(items.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ export async function initDB(this: ITriggerFunctions | ILoadOptionsFunctions) {
}

export async function searchSchema(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
const { db, pgp } = await initDB.call(this);
const { db } = await initDB.call(this);
const schemaList = await db.any('SELECT schema_name FROM information_schema.schemata');
const results: INodeListSearchItems[] = (schemaList as IDataObject[]).map((s) => ({
name: s.schema_name as string,
value: s.schema_name as string,
}));
pgp.end();
await db.$pool.end();
return { results };
}

export async function searchTables(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
const schema = this.getNodeParameter('schema', 0) as IDataObject;
const { db, pgp } = await initDB.call(this);
const { db } = await initDB.call(this);
let tableList = [];
try {
tableList = await db.any(
Expand All @@ -138,6 +138,6 @@ export async function searchTables(this: ILoadOptionsFunctions): Promise<INodeLi
name: s.table_name as string,
value: s.table_name as string,
}));
pgp.end();
await db.$pool.end();
return { results };
}
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Postgres/PostgresTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class PostgresTrigger implements INodeType {
const additionalFields = this.getNodeParameter('additionalFields', 0) as IDataObject;

// initialize and connect to database
const { db, pgp } = await initDB.call(this);
const { db } = await initDB.call(this);
const connection = await db.connect({ direct: true });

// prepare and set up listener
Expand Down Expand Up @@ -284,7 +284,7 @@ export class PostgresTrigger implements INodeType {
`Postgres Trigger Error: ${(error as Error).message}`,
);
} finally {
pgp.end();
await db.$pool.end();
}
};

Expand Down
8 changes: 4 additions & 4 deletions packages/nodes-base/nodes/Postgres/v1/PostgresV1.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class PostgresV1 implements INodeType {

const db = pgp(config);
await db.connect();
pgp.end();
await db.$pool.end();
} catch (error) {
return {
status: 'Error',
Expand Down Expand Up @@ -412,15 +412,15 @@ export class PostgresV1 implements INodeType {

returnItems = wrapData(updateItems);
} else {
pgp.end();
await db.$pool.end();
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
);
}

// Close the connection
pgp.end();
// shuts down the connection pool associated with the db object to allow the process to finish
await db.$pool.end();

return [returnItems];
}
Expand Down
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/QuestDb/QuestDb.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ export class QuestDb implements INodeType {

returnItems = this.helpers.returnJsonArray(insertData);
} else {
pgp.end();
await db.$pool.end();
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
);
}

// Close the connection
pgp.end();
// shuts down the connection pool associated with the db object to allow the process to finish
await db.$pool.end();

return [returnItems];
}
Expand Down
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ export class TimescaleDb implements INodeType {

returnItems = this.helpers.returnJsonArray(updateItems);
} else {
pgp.end();
await db.$pool.end();
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
);
}

// Close the connection
pgp.end();
// shuts down the connection pool associated with the db object to allow the process to finish
await db.$pool.end();

return [returnItems];
}
Expand Down
Loading