Skip to content

fix(tests): revert template-database cloning, restore per-file migrations - #101

Merged
KenTaniguchi-R merged 1 commit into
mainfrom
fix/revert-test-template-clone
Aug 29, 2026
Merged

fix(tests): revert template-database cloning, restore per-file migrations#101
KenTaniguchi-R merged 1 commit into
mainfrom
fix/revert-test-template-clone

Conversation

@KenTaniguchi-R

Copy link
Copy Markdown
Owner

Why

main is red. #98 broke it. Every integration file times out in beforeAll:

Test Files  57 failed | 56 passed (113)
Error: Hook timed out in 10000ms.
  185|   beforeAll(async () => {
  186|     ({ db, close } = await createTestDb());

All 56 unit files pass; all 57 integration files fail. Run: https://github.com/KenTaniguchi-R/ledgr/actions/runs/33279632754

What went wrong

#98 replaced per-file migrations with a template database cloned via CREATE DATABASE ... TEMPLATE. That statement takes a lock on the source database, so concurrent clones serialize instead of running in parallel — on the CI runner they block past the 10s hook timeout.

The deeper mistake was the measurement. The change was validated only on a 14-core dev machine, where pnpm test went 339s → 21s. That speedup was real, but the problem it solved was local: 14 vitest workers × pg's default pool of 10 overran max_connections=100. CI has fewer cores, never hit that limit, and ran the same suite in 27 seconds before the change. The PR claimed a CI benefit that was never measured on CI.

What this does

Restores tests/global-setup.ts and tests/integration/setup.ts to their pre-#98 state (from 402a877).

Keeps the .stryker-tmp ESLint ignore from #98 — unrelated to the failure, independently verified, takes pnpm lint from 1024 errors to 0.

Verification

Check Result
pnpm install --frozen-lockfile clean
pnpm typecheck clean
pnpm lint 0 errors (1 pre-existing warning)
Integration 305 passed / 305

Honest caveat: one of three local runs showed 3 failures that did not reproduce. That is the pre-existing flakiness of the original code returning along with it — this PR restores the prior behavior, warts included. It does not claim to improve on it.

Follow-up, not included here

The local connection exhaustion is real and worth fixing, but belongs in a maxWorkers cap in vitest.config.ts — local-only, costs CI nothing. Deliberately left out so this change does one thing: restore green.

🤖 Generated with Claude Code

…ions

#98 replaced per-file migrations with a template database that each test
file cloned via CREATE DATABASE ... TEMPLATE. That broke CI: every
integration file now times out in beforeAll at createTestDb().

    Test Files  57 failed | 56 passed (113)
    Error: Hook timed out in 10000ms.
      185|   beforeAll(async () => {
      186|     ({ db, close } = await createTestDb());

CREATE DATABASE ... TEMPLATE takes a lock on the source database, so
concurrent clones serialize rather than run in parallel. On the CI runner
they block past the 10s hook timeout.

The change was measured only on a 14-core dev machine, where the suite
went 339s -> 21s. That speedup was real but local: the problem it solved
— pool connections (14 workers x pg's default 10) overrunning
max_connections=100 — never occurred on CI, which has fewer cores and ran
the same suite in 27s beforehand.

Restore tests/global-setup.ts and tests/integration/setup.ts to their
pre-#98 state. The .stryker-tmp ESLint ignore from #98 is unrelated and
stays; it takes `pnpm lint` from 1024 errors to 0.

The local exhaustion is better addressed with a maxWorkers cap, which
costs CI nothing. Not included here — this commit only restores green.
@KenTaniguchi-R
KenTaniguchi-R merged commit 9df8b9b into main Aug 29, 2026
6 of 7 checks passed
@KenTaniguchi-R
KenTaniguchi-R deleted the fix/revert-test-template-clone branch August 29, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant