In our codebase we sometimes have accidental transaction leaks where a transaction is opened with Knex but never closed. As a safety net we want to introduce a way to automatically close connections that are idle in transaction longer than a certain amount of time. This is so our platform won't break if we mistakenly introduce a transaction leak.
We tried setting the idle_in_transaction_session_timeout parameter in Postgres, and it does work to close idle transactions. However, Knex does not release those connections from its pool (as described in this issue), so we still get breakdown in functionality when there's enough idle transactions.
There's also an idleTimeoutMillis parameter that can be applied to the Knex pool config, but this timeout only works to close idle sessions, and not idle in transaction sessions.
What is the best way to either get around these limitations or set up an automated setting to close idle in transaction sessions that doesn't cause issues in Knex or postgres?