how to close underlying connection pool being used by drizzle?
hello all,
in my test cases i have those before and after hooks:
however the try/catch seems to be ineffective.
it always ends up like this:
comparing the code with a similar one made with knex, knex offers a destroy method.
is there anything similar in drizzle so i can close connections before shut down the test container?
any tip is welcome, thanks in andvance.
in my test cases i have those before and after hooks:
test.before(async t => {
t.timeout(30000, 'waiting for the database to be ready')
const initScript = resolve(__dirname, '..', '..', 'infrastructure', 'dev-schema.sql');
// @ts-ignore
t.context.pg = await new PostgreSqlContainer()
.withBindMounts([{
source: initScript,
target: '/docker-entrypoint-initdb.d/init.sql',
}])
.start();
// @ts-ignore
t.context.db = await prepareDb(t.context.pg.getConnectionUri())
// @ts-ignore
t.context.server = await prepareServer(t.context.db)
})
test.after.always(async t => {
try {
// @ts-ignore
await t.context.pg.stop({timeout: 500})
} catch (e) {
// swallow for now
}
})test.before(async t => {
t.timeout(30000, 'waiting for the database to be ready')
const initScript = resolve(__dirname, '..', '..', 'infrastructure', 'dev-schema.sql');
// @ts-ignore
t.context.pg = await new PostgreSqlContainer()
.withBindMounts([{
source: initScript,
target: '/docker-entrypoint-initdb.d/init.sql',
}])
.start();
// @ts-ignore
t.context.db = await prepareDb(t.context.pg.getConnectionUri())
// @ts-ignore
t.context.server = await prepareServer(t.context.db)
})
test.after.always(async t => {
try {
// @ts-ignore
await t.context.pg.stop({timeout: 500})
} catch (e) {
// swallow for now
}
})however the try/catch seems to be ineffective.
it always ends up like this:
Uncaught exception in app/Server.spec.ts
error: terminating connection due to administrator command
error: terminating connection due to administrator command
at Parser.parseErrorMessage (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/parser.ts:369:69)
at Parser.handlePacket (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/parser.ts:188:21)
at Parser.parse (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/parser.ts:103:30)
at Socket.<anonymous> (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/index.ts:7:48)
(...)
✘ app/Server.spec.ts exited with a non-zero exit code: 1
─
3 tests passed
1 uncaught exception
Process finished with exit code 1 Uncaught exception in app/Server.spec.ts
error: terminating connection due to administrator command
error: terminating connection due to administrator command
at Parser.parseErrorMessage (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/parser.ts:369:69)
at Parser.handlePacket (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/parser.ts:188:21)
at Parser.parse (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/parser.ts:103:30)
at Socket.<anonymous> (/home/sombriks/git/game-shark/api/node_modules/pg-protocol/src/index.ts:7:48)
(...)
✘ app/Server.spec.ts exited with a non-zero exit code: 1
─
3 tests passed
1 uncaught exception
Process finished with exit code 1comparing the code with a similar one made with knex, knex offers a destroy method.
is there anything similar in drizzle so i can close connections before shut down the test container?
any tip is welcome, thanks in andvance.