Skip to content
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
2 changes: 1 addition & 1 deletion graphql/server/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ afterAll(async () => {
await new Promise<void>((resolve) => server!.close(() => resolve()));
server = null;
}
await teardown();
await closePgPools();
await teardown();
});

beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion postgres/pgsql-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class PgClient {
if (!this._ended) {
this._ended = true;
await this.ensureConnected();
this.client.end();
await this.client.end();
}
}

Expand Down
8 changes: 5 additions & 3 deletions postgres/pgsql-test/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const log = new Logger('test-connector');

const SYS_EVENTS = ['SIGTERM'];

const end = (pool: Pool) => {
const end = async (pool: Pool): Promise<void> => {
try {
if ((pool as any).ended || (pool as any).ending) {
log.warn('⚠️ pg pool already ended or ending');
return;
}
pool.end();
await pool.end();
} catch (err) {
log.error('❌ pg pool termination error:', err);
}
Expand Down Expand Up @@ -123,11 +123,13 @@ export class PgTestConnector {
this.clients.clear();

log.info('🧯 Disposing pg pools...');
const poolTasks: Promise<void>[] = [];
for (const [key, pool] of this.pgPools.entries()) {
log.debug(`🧯 Disposing pg pool [${key}]`);
end(pool);
poolTasks.push(end(pool));
}
this.pgPools.clear();
await Promise.allSettled(poolTasks);

if (keepDb) {
log.info('📦 Keeping databases (keepDb=true)...');
Expand Down