Skip to content

fix(test): Deno API suite is flaky at +/-2, so it cannot detect regressions #478

Open

Description

@thinkclay

The Deno API test suite is flaky. Two consecutive runs of identical code, same database, no changes in between:

FAILED | 129 passed | 61 failed (1m48s)
FAILED | 130 passed | 60 failed (1m37s)

So results move by about ±2 run to run. Combined with a large standing failure count (~59 on a freshly reset DB, largely the ES256/auth.uid() problem tracked previously), the suite currently cannot distinguish a real regression from noise — which is precisely the situation where a genuine break slips in unnoticed.

Baseline for reference, freshly reset local DB, all 177 migrations, standard seed: 119 passed / 59 failed.

Likely cause: tests share one local database and create/clean fixtures around each other — cleanupCurrentTestData plus markTestStart suggest ordering assumptions that concurrent execution breaks. Worth checking whether Deno's default parallelism is fighting the fixtures.

Why it matters

Any PR touching this API has to hand-diff failure names against a stashed baseline to claim "no new failures", because the counts alone are not trustworthy. That is what I did for #443. It should not be necessary.

Suggested

  1. Make the suite deterministic — per-test schema/transaction isolation, or force serial execution.
  2. Then fix or explicitly skip the standing failures so the suite can gate merges.

Related: #469 covers a similar "tests silently do not run" problem in packages/ui.

Activity

  1. added
    bug
    on Jul 30, 2026
  2. thinkclay commented on Sep 2, 2026

    @thinkclay
    ContributorAuthor

    The ±2 flakiness does not reproduce. Three consecutive runs, same database, nothing changed between them:

    205 passed | 185 failed  (51s)
    205 passed | 185 failed  (46s)
    205 passed | 185 failed  (48s)
    

    Not just the counts — the sets of failing test names are byte-identical across all three. Zero in run 1 that are not in run 3, zero the other way. Whatever produced the ±2 in March is gone, so "make the suite deterministic" is no longer the work.

    What is left is worse in a different way: 132 of the 185 failures are a single cause.

    101x   Auth setup is incomplete. Run auth.test.ts first.
     31x   Failed to get or create auth token
    

    Those suites call requireAuthSetup() → reads tests/fixtures/tokens.json → written only by auth.test.ts → which fails first, because the magic link it is handed is unparseable:

    TypeError: Invalid URL: 'env%28EXPO_PUBLIC_URL%29/auth/confirm?token_hash=...'
    

    config.toml:52 is site_url = "env(EXPO_PUBLIC_URL)" and the CLI never substituted it — docker exec supabase_auth_scaffald env shows GOTRUE_SITE_URL=env(EXPO_PUBLIC_URL) literally. pnpm supa reads .env, and EXPO_PUBLIC_URL exists only in .env.template.

    So the original diagnosis — shared fixtures fighting Deno's parallelism — was reasonable but is not what is happening. The suite is perfectly repeatable; it is repeatably broken by one unset variable, and the ordering assumption in cleanupCurrentTestData / markTestStart was a red herring.

    #710 fixes what can be fixed without restarting someone else's stack:

    • TEST_USERS.regular used testpassword123; seeds/002a creates the user with test123456. Measured: seeded password → 200, the constant → 400. 185 → 170 from that alone.
    • TEST_USERS.admin was never created by anything — no [email protected] in auth.users. New seed 002b.
    • completeMagicLinkAuth() now detects the literal env( and says what is unset, instead of a TypeError that resurfaces 132 times as something else.

    Two things this leaves open, both worth deciding on:

    1. tokens.json is a hard ordering dependency — a whole suite hinging on a file one test happens to write. That is fragile regardless of the site_url bug, and is the part of the original "ordering assumptions" instinct that was right.
    2. Cleanup leaks. 16 orphaned ccpa-test-* / deadline-test-* users are sitting in auth.users from earlier runs, so cleanupCurrentTestData's wall-clock window is not catching everything it creates.

    Suggest retitling this issue toward the standing failure count, since determinism is now measured and fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions