← Back to Pull requests

test(auth): the setup hooks that build the auth schema get 30 seconds, so a slow CI database no longer fails them #445

Closed
unknown closed this pull request without merging on Nov 20, 2026 03:43 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 02:41 UTC
Author

The Linux "Test" job failed once with this, and passed on a rerun:

(fail) startLocalAuthServer — email wired to the real outbox > (unnamed) [5002.00ms]
  ^ a beforeEach/afterEach hook timed out for this test.
error: local auth bootstrap: Prisma ORM dbInit failed: … add FK "session_userId_fkey" — terminating connection due to administrator command.

The decision

The setup hooks that build the auth schema in a test database now have 30 seconds, in place of bun's default of 5.

Why

The setup hook was slow, and nothing else was wrong. The dropped connection is a result of the timeout, not its cause.

  • The hook creates a database, starts the local email server, then runs the ORM's dbInit. That normally takes 1 to 2 seconds.

  • In the failed run, the Postgres container's log shows dbInit starting at 11:07:49.1 and still adding a foreign key at 11:07:53.6. In the same seconds Postgres spent 1.6 seconds on one checkpoint that wrote 2,520 buffers, because other packages' suites were creating and dropping databases on the same container.

  • When bun's 5 seconds ran out, it ran the afterAll hook. That hook drops the test database, and to do so it first terminates the database's connections. One of them was the dbInit still running, which is the "terminating connection due to administrator command" in the log.
  • The timeout is a named constant, SCHEMA_BOOTSTRAP_TIMEOUT_MS, exported from the two Postgres test harnesses. It applies to the six hooks that call startLocalAuthServer or ensureLocalAuthSchema: five in the auth package and one in examples/auth. The two tests in pack-conformance.integration.test.ts that run the same bootstrap in their bodies get it too.

    How it was checked

  • bun 1.3.13 accepts a timeout as the second argument of beforeAll: a hook that sleeps 6 seconds passes with it and times out without it.

  • The five changed test files in the auth package pass against a local Postgres (55 tests). Lint and the package's typecheck pass.

  • I did not run the examples/auth test locally. CI runs it.
  • Alternatives considered

  • Raise the timeout for every test in the package (bun test --timeout). Rejected: it would also let a test that hangs run six times longer before it fails.

  • Give the other packages' database suites the same timeout. Not done: only the auth schema bootstrap has timed out, and it is the slowest of these setups.
  • Refs TML-3894

    Agent: selene-35

    🤖 Generated with Claude Code

    Diff: 314 lines (+235 / -79) across 3 files Reviewer: wmadden Review duration: 62m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.64) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.64 · 314 lines diff across 3 files
    0.64
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.344
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.064
    Real PR Conversation Timeline
    1 comments
    "Review active on #445"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 63.5% (MEDIUM) · Higher = larger blast radius
    63.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.5% · Safe to merge
    27.5%