From 1a3084a6ee53a1e8cd86b9f05172ab19fa54018a Mon Sep 17 00:00:00 2001 From: Francisco Solla Date: Wed, 5 Aug 2026 20:29:14 -0300 Subject: [PATCH] fix(test): keep int gate under Postgres connection ceiling Cap vitest workers and raise Docker max_connections so high-core laptops stop failing the suite with cascading "too many clients" / QueryError noise. --- docker-compose.yml | 4 ++++ vitest.config.mts | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 204478df..b469ebb2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,10 @@ services: POSTGRES_DB: teqo ports: - '5432:5432' + # Default max_connections=100 is tight for vitest forks (≈CPUs × pg pool) + # plus a leftover `next start` from local repro. Raise the ceiling so the + # int gate fails on real assertions, not "too many clients already". + command: ['postgres', '-c', 'max_connections=200'] volumes: - pgdata:/var/lib/postgresql/data # Runs only on first initialization of the volume. Creates the dedicated diff --git a/vitest.config.mts b/vitest.config.mts index 2915ee18..460d5f6f 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -15,9 +15,14 @@ export default defineConfig({ environment: 'jsdom', setupFiles: ['./vitest.setup.ts'], include: ['tests/int/**/*.int.spec.ts'], - // Int specs hit a real Postgres under a ~48-way parallel suite, so wall - // time is dominated by pool contention, not by the code under test. The - // 5s default made legitimately heavy RSC-composition tests flake as the + // Cap forks so each worker's Payload pg pool stays under Docker Postgres + // max_connections=100 on high-core laptops (default worker count ≈ CPUs; + // 16× pool-max-10 ≈ 160 clients → "too many clients already", which then + // cascades into unrelated QueryError noise). CI runners have fewer CPUs. + maxWorkers: 8, + // Int specs hit a real Postgres under a parallel suite, so wall time is + // dominated by pool contention, not by the code under test. The 5s + // default made legitimately heavy RSC-composition tests flake as the // suite grew (municipalityPageData was the first); one global budget // beats per-test overrides. Genuinely hung tests still fail — just 10s // later. The unit suite keeps the 5s default.