From 8207b7feea801e7e086f7dca273f5e17770d3ae7 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Thu, 2 Oct 2025 15:48:01 -0600 Subject: [PATCH] fix: force close db connection after a configurable timeout --- src/env.ts | 1 + src/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/env.ts b/src/env.ts index 2b16d09f..653d3f8c 100644 --- a/src/env.ts +++ b/src/env.ts @@ -62,6 +62,7 @@ const schema = Type.Object({ PG_CONNECTION_POOL_MAX: Type.Number({ default: 10 }), PG_IDLE_TIMEOUT: Type.Number({ default: 30 }), PG_MAX_LIFETIME: Type.Number({ default: 60 }), + PG_CLOSE_TIMEOUT: Type.Number({ default: 10 }), STACKS_NODE_RPC_HOST: Type.String(), STACKS_NODE_RPC_PORT: Type.Number({ minimum: 0, maximum: 65535 }), diff --git a/src/index.ts b/src/index.ts index 66d36b99..eaf8ae75 100644 --- a/src/index.ts +++ b/src/index.ts @@ -102,7 +102,7 @@ async function initApp() { name: 'DB', forceKillable: false, handler: async () => { - await db.close(); + await db.close({ timeout: ENV.PG_CLOSE_TIMEOUT }); }, }); }