This commit is contained in:
NoLogicAlan committed 2026-10-06 02:37:08 +03:00
1 parent 8c743b96fa
commit 93bb92b109
1 file changed
+9
+9
View File
@@ -40,10 +40,19 @@ import { logger } from "../core/Logger.mjs";
* `enableKeepAlive` is the critical one — without TCP keepalive probes, a * `enableKeepAlive` is the critical one — without TCP keepalive probes, a
* connection parked in the pool behind a NAT/firewall is silently dropped and * connection parked in the pool behind a NAT/firewall is silently dropped and
* the next query on it dies with read ETIMEDOUT. * the next query on it dies with read ETIMEDOUT.
*
* `maxIdle` and `idleTimeout` switch on mysql2's idle-connection reaper, which
* only runs when `maxIdle` is below `connectionLimit` (by default they are
* equal, so it never starts). With them set, spare idle connections are closed
* client-side after 30s, before a short server-side `wait_timeout` can kill
* them (error 4031). Must stay above `keepAliveIntervalMs` (20s) so the pinged
* connection is never reaped.
*/ */
const MYSQL_POOL_DEFAULTS = { const MYSQL_POOL_DEFAULTS = {
enableKeepAlive: true, enableKeepAlive: true,
keepAliveInitialDelay: 10_000, keepAliveInitialDelay: 10_000,
maxIdle: 1,
idleTimeout: 30_000,
}; };
/** /**