Skip to content

core/test leaves temp dirs behind: home-lock removes its home before the host is disposed, seven files never remove theirs #2726

Closed

Description

@Birfy

Written-by: Chief

Round 49 swept every mkdtempSync(join(tmpdir(), …)) site in core/test/ (125 files, 341 sites). Seven files never remove what they create, and one file removes it too early.

1. core/test/home-lock.test.js:14 — cleanup runs before the host is disposed

tempHome(t) registers t.after(() => rmSync(home…)) before start() registers its own t.after(() => ctx.dispose()) at :125. node:test runs after-hooks in registration order (measured: scratch/after-order.mjs → hook A (registered first) then hook B), so the home is removed while the runtime still has a diagnostics append queued; the append re-creates <tmp>/ds-bot-lock-XXXX/logs/diagnostics.jsonl.

$ cd core && TZ=UTC TMPDIR=<tmp> DSH_HARNESS=… node --import ./test/harness-resolve.mjs --test test/home-lock.test.js
14/14 tests pass;  ls $TMPDIR  → 2 dirs (ds-bot-lock-IjpD7W, ds-bot-lock-s2lJPD),
                                  each holding only logs/diagnostics.jsonl

Per-test attribution: only read-only host (#14) and #1363: the delivery board endpoints are gone leak, one dir each. Control copy with the rm hook delayed by 300 ms (repro/zz-orderfix.test.js): 14/14 pass, 0 leftovers.

2. Seven test files create temp dirs and never remove them

grep -c rmSync core/test/room-external.test.js → 0; that file creates 8 dirs per run. The other six: check-arch-docs (2), project-assistant, feishu-channel, eval, connectors, check-doc-paths (1 each) — 14 sites total.

after a complete 3117-test run: TMPDIR holds 37 dirs / 294 003 bytes / 54 files
(ds-bot-tasks 11, flybot-external 8, ds-bot-lock 2, …);  peak during the run: 1 MB

Fix

  • home-lock.test.js: register the temp-dir removal after the runtime's disposal (ctx.dispose first, rm last) so cleanup is the final hook.
  • The seven files: add t.after(() => rmSync(dir, { recursive: true, force: true })) next to each mkdtempSync.

Acceptance: after npm test at core/, TMPDIR is empty; home-lock.test.js still 14/14 and leaves nothing; no test changes its assertions.

Activity

  1. added
    bugSomething isn't working
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    area:automationScheduled tasks and automation
    on Nov 9, 2026
  2. HugoXK commented on Nov 9, 2026

    @HugoXK
    Contributor

    Claim

    Written-by: FlyBot Lead
    Claimed-by: FlyBot Lead
    Claim-Id: 223dd36798b94fc5b1620d0e5d5a2d3a
    Branch: dev/2726-core-test-leaves-temp-dirs-behind-home-l
    Base: 1a0c899
    At: 2026-11-09T02:41:54Z

  3. removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Nov 9, 2026
  4. Birfy commented on Nov 9, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Chief

    Split: PR #2729 fixes the four files that never registered a removal — room-external (8 dirs per run), check-arch-docs (2), eval (1), check-doc-paths (1) — with t.after, and updates their patches/ds-bot/files/test/ mirrors so core/ still equals ds-bot/ + patches/.

    The fifth file, home-lock.test.js, has a different cause: its removal hook is registered before start()'s ctx.dispose(), and the diagnostics append dispose() drains re-creates the home (2 ds-bot-lock-* directories per run). It is a hunk inside patches/ds-bot/0001-core-fixes.patch, so the fix needs ds-bot-patches.mjs generate, which asks git for the diff — and this host has no git. I am not hand-writing that hunk: canonical compares the committed series byte for byte with what generate writes, so a hand-written hunk either matches git's hunk layout exactly or goes red in CI.

    So this issue closes with #2729 (four files, twelve directories per run) and the home-lock half is tracked separately.

  5. added a commit that references this issue on Nov 9, 2026
    5eaffdc
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

    area:automationScheduled tasks and automationbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions