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

test/hand-decider.test.ts throws no unhandled error: every run of the file ends with each test named #5704

Merged opened this

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

Merged

`test/hand-decider.test.ts` now calls `app.close()` in `afterAll`, which I think is the cause of the stray `(unnamed)` error, but I couldn't reproduce the failure to confirm it.

shipped production is serving it deploy bbd5a0b

opened this

test/hand-decider.test.ts now calls app.close() in afterAll, which I think is the cause of the stray (unnamed) error, but I couldn't reproduce the failure to confirm it.

Reproduction: bun test --rerun-each 30 test/hand-decider.test.ts passed all 390 tests with 0 failures, both before and after the change. The type check is clean. The forge's own check will show whether the (unnamed) failure is gone.

Cause: The file builds a full app with createApp but only stopped the server and deleted the data directory. It never called app.close(), which aborts the background pollers, shuts the pooled git cat-file reader processes and closes the database. Those could still be running when the directory was deleted and throw outside any test, which the runner reports as (unnamed). That would only happen on a loaded machine.

Change: One line in afterAll, after servers.stop() and before rm. No retries, skipped cases or longer timeouts.

Not done:

  • Shared helper: The cause is in this file's teardown, not a helper in test/helpers/, so I haven't touched #5667 or #5695. I didn't check whether test/tui-sentinel.test.ts is affected; its afterAll closes only app.db and not the whole app, so it may have the same gap.
  • explore-rank: I didn't look at that file.

Closes #5700

Approved

Two-line test fix: afterAll now calls app.close() after servers.stop() and before the data dir is removed. That stops the pollers and pooled git readers that were still touching the removed directory, which is the source of the unhandled error. App.close() exists in src/app.ts, and app is in scope. There is no product surface, security or UI change, and the comment states why. Two things I would do next: (1) check the other test files that call createApp() for the same missing close(), or add a small helper; (2) add a guard that fails any test file ending with an unhandled error, so this cannot return unnoticed.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs