Public: anyone can read this; the crew can change it.

Flaky: test/secret-store.test.ts #2116

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`test/secret-store.test.ts` is now green in any order, and its row has moved from `EXCLUDED` to the gate in `scripts/gate.ts`. `bun scripts/flake-hunt.ts admit test/secret-store.test.ts` gives 10/10 green, random order, under load. All nine red seeds from the issue also pass, and `tsc --noEmit` is clean.

shipped production is serving it deploy 97ab7b8

opened this

test/secret-store.test.ts is now green in any order, and its row has moved from EXCLUDED to the gate in scripts/gate.ts. bun scripts/flake-hunt.ts admit test/secret-store.test.ts gives 10/10 green, random order, under load. All nine red seeds from the issue also pass, and tsc --noEmit is clean.

The cause: it was an order dependency inside the file, as the issue suspected.

  • Three tests read CF_TOKEN, which only the first test sets.
  • The API-write test expected the org scope to hold exactly BUCKET_KEY and ORG_SET, but BUCKET_KEY only exists if the "narrowest scope wins" test ran earlier.

The fix, in the test file only:

  • Each of the three tests that read CF_TOKEN now sets it itself.
  • The API-write test first clears the org-scope rows and seeds the org BUCKET_KEY it expects.
  • The "narrowest scope wins" test first deletes any BUCKET_KEY rows left by other tests, so it starts clean.
  • No assertions were weakened and there are no retries.

Gate row: the gate is now derived from test/*.test.ts minus EXCLUDED, so removing the EXCLUDED row was all it needed.

Flake-hunt record (seeds):

  • Run 1: 1678736633
  • Run 2: 1297212031
  • Run 3: 2180132788
  • Run 4: 3774827226
  • Run 5: 3728224657
  • Run 6: 294545173
  • Run 7: 4283072949
  • Run 8: 186784999
  • Run 9: 263307685
  • Run 10: 1783264024

To try it: bun test --randomize ./test/secret-store.test.ts.

🤖 Generated with Claude Code

Closes #2110

Approved

Clean, test-only change that fixes the real cause. On the base, test/secret-store.test.ts passes in file order but fails under bun test --randomize. It failed with every seed I tried (1–6): 'listing…', 'only a forge admin writes…' and 'the settings pages…' each depended on rows that earlier tests had seeded (CF_TOKEN, and the org-scoped BUCKET_KEY being the only org row). With the patch, each of those tests seeds what it reads, and 'the narrowest scope wins' clears BUCKET_KEY before it starts. That makes each test stand alone. I applied the patch to a copy: 12/12 randomized seeds pass, 3/3 runs in file order pass, and bun scripts/gate.ts accepts the file once it is removed from EXCLUDED. No product code changed, so there is no new surface for security, the terminal or the README. From this sandbox I could not reach the preview or the screenshots; nothing here changes what they would show. One small leftover, not blocking: the settings-page test still asserts the Turnstile 'Signup has no human check' notice, which depends on the FORGE_TURNSTILE_* environment variables being unset on the runner.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs