Skip to content

Test helpers leak temp dirs into os.tmpdir() on every test run #7884

Description

@smsunarto

Summary

createFakePluginHost (packages/plugin-sdk/src/testing/fake-plugin-host.ts) creates a bb-fake-plugin-host-* dir under os.tmpdir() for every host and removes it only in dispose(), so every test that skips dispose() leaks one. Other test helpers leak the same way: the agent-runtime scripted-echo harness, the parity replay default dataDir, and about a dozen individual tests. One machine running plugin tests had more than 23,000 of these dirs (3.8 GB).

Versions and environment

main at b629714, Node 24.22.2, macOS, vitest 4.1.1.

Steps to reproduce

T=$(mktemp -d)
TMPDIR=$T pnpm exec turbo run test --filter=@get-bb/plugin-sdk --env-mode=loose --force
ls "$T" | grep -c bb-fake-plugin-host

--env-mode=loose is needed because turbo strips TMPDIR otherwise, which sends tests to /tmp.

Expected vs actual

  • Expected: 0
  • Actual: 69. Other suites on main left: agent-runtime 392, bb-app 59, provider-parity 48, simple-notes plugin 31.

Evidence

process.on("exit") cleanup can't help: vitest stops its fork workers with SIGTERM, so exit never fires. A probe confirmed this in both shared and isolated workers.

What you ruled out

The tool caches (tsx-*, jiti, node-compile-cache) are not counted.

AGENT GENERATED

Activity

  1. added theissue type on Nov 20, 2026
  2. added
    plugins
    no-repro
    on Nov 20, 2026
  3. bb-slop-cop commented on Nov 20, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium · labels: plugins, no-repro.
    • Reproduction and root-cause report — ALREADY FIXED, root-cause confidence high.
    • Verification: two trusted-main checkouts at 9f4c15646d; each full SDK run passed 444 tests and left 0 fake-host directories and 0 runner sandboxes. These were Linux runs; macOS was not rechecked.
    • Root cause: helper-local storage still depends on explicit disposal, but the shared runner now owns the entire temporary tree and removes it after the last project finishes. This protection landed in Sandbox test TMPDIR so vitest runs stop leaking temp directories #3638 on September 14, 2026, after the cited August 27, 2026 baseline.
    • No new PR: the bug did not reproduce on current main, and open Stop test helpers leaking temp dirs into tmpdir() #7882 already links this issue. Its code was not executed.

    AGENT GENERATED

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

    no-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions