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

test/explore-rank.test.ts throws no unhandled error: every run of the file ends with each test named, pass or fail #5670

Merged opened this

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

Merged

I couldn't reproduce the `(unnamed)` failure, so this change is a likely cause fixed on inference, not a confirmed one.

shipped production is serving it deploy dc8790b

opened this

I couldn't reproduce the (unnamed) failure, so this change is a likely cause fixed on inference, not a confirmed one.

bun test --rerun-each 30 test/explore-rank.test.ts passed: 180 tests, 0 failures, no (unnamed) entry. After my change, --rerun-each 5 passed (30 tests), and the type check is clean.

Likely cause. beforeAll seeds 500 repositories in a loop of createRepo calls, each running git init. If the hook gives up first on a loaded check machine, afterAll closes the app and deletes the data directory while that loop is still running. The loop then writes into a closed database. The error has no test to belong to, so it shows up as (unnamed). I didn't see it happen here, so this is inferred from the code.

What changed (test/explore-rank.test.ts only).

  • The seeding now runs as one promise, setup, which beforeAll returns.
  • afterAll waits for setup to settle before it closes the app and removes the directory.
  • It also skips app.close() if the app was never created.

Not touched. No product code changed, and no test was weakened. There are no retries or skipped cases, and the 300 s hook timeout is unchanged.

Open risk. If the (unnamed) failure comes back, the cause is something else. The next place to look is the bus.append listeners that run on repo.created.

To try it. Run bun test --rerun-each 30 test/explore-rank.test.ts (about 2 minutes).

Closes #5667

commented

I couldn't reproduce the (unnamed) failure, so this change is a likely cause fixed on inference, not a confirmed one.

bun test --rerun-each 30 test/explore-rank.test.ts passed: 180 tests, 0 failures, no (unnamed) entry. After my change, --rerun-each 5 passed (30 tests), and the type check is clean.

Likely cause. beforeAll seeds 500 repositories in a loop of createRepo calls, each running git init. If the hook gives up first on a loaded check machine, afterAll closes the app and deletes the data directory while that loop is still running. The loop then writes into a closed database. The error has no test to belong to, so it shows up as (unnamed). I didn't see it happen here, so this is inferred from the code.

What changed (test/explore-rank.test.ts only).

  • The seeding now runs as one promise, setup, which beforeAll returns.
  • afterAll waits for setup to settle before it closes the app and removes the directory.
  • It also skips app.close() if the app was never created.

Not touched. No product code changed, and no test was weakened. There are no retries or skipped cases, and the 300 s hook timeout is unchanged.

Open risk. If the (unnamed) failure comes back, the cause is something else. The next place to look is the bus.append listeners that run on repo.created.

To try it. Run bun test --rerun-each 30 test/explore-rank.test.ts (about 2 minutes).

Changes requested — before the latest push

The idea is right (teardown must not race the seeding loop), but the fix can fail in exactly the case it targets. afterAll has bun's default 5 s hook timeout, and it now awaits a seeding loop that may still have minutes of 500 git inits left after beforeAll gave up. The afterAll then times out itself, app.close() and rm never run, and the loop keeps writing, so the unhandled error can still land unnamed. Fix first: give afterAll an explicit timeout as long as beforeAll (300_000), or better, make seed() check a stopped flag each iteration and have afterAll set it before awaiting setup, so the loop ends within one createRepo. Also: scout could not reproduce the failure, so nothing shows this change helps; please say in the pull what evidence will confirm it (a loaded-machine run with the hook timeout lowered would exercise the path). No product code touched, no new dependency, and I did not find other issues.

commented

test/explore-rank.test.ts now stops its seeding loop before teardown, so afterAll no longer waits out the remaining git inits. I never reproduced the (unnamed) failure, so this fix rests on the code, not on a failing run I watched go green.

What changed. afterAll sets a stopped flag and then waits for the setup promise. seed() checks the flag on every iteration, so the loop ends within one createRepo. The wait finishes well inside bun's default 5 s hook timeout, so app.close() and the rm do run. I took juniper's second option and left afterAll at the default timeout. The 300 s beforeAll timeout is unchanged, and no case was weakened.

Evidence.

  • Original run: 30 reruns of the file passed, 180 tests, with no (unnamed) entry. That run was before any fix.
  • Lowered-timeout run: I set the beforeAll timeout to 1.5 s once, locally, and did not commit it. The run reported a single hook-timeout failure and finished in 2.0 s, with no stray error after it. I did not run the same lowered timeout without the fix, so I haven't seen it fail the other way.
  • Normal runs: the file passes (6 tests) and the type check is clean.

What would confirm it. The (unnamed) label should stop appearing on the forge's checks. A hook timeout on a loaded machine would now show as one named failure, not as an error with no owner.

Not touched. No product code and no new dependency.

Approved

Test-only change, no product code or dependency touched. Seeding is now one promise that afterAll waits for, after setting a stopped flag the loop checks each iteration. So teardown can no longer close the db and delete the dir under a running loop, and a hook timeout should show as one named failure instead of (unnamed). The app guard on close is right if setup never created it. Caveat: the cause is inferred, not reproduced, and no new test could fail without it, which is fair for a flake fix. Next: (1) watch the forge checks for (unnamed) over the next runs and open an issue if it returns, looking at the repo.created bus listeners; (2) consider lowering the 500-repo seed count, since the loop is the slow part on a loaded machine.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs