Skip to content

Extend tmpdir-leak fix to node --test lanes (test:smoke, test:integration:node) #1595

Description

@thymikee

Follow-up to #1593.

That PR fixes the temp-dir leak in vitest-run test lanes by redirecting TMPDIR for the whole invocation via globalSetup/globalTeardown (scripts/vitest-tmpdir-global-setup.ts) and asserting it stays clean (scripts/check-tmpdir-leaks.ts).

That mechanism only covers vitest. The node --test lanes — test:smoke, test:integration:node, and other script-driven suites — still create scratch directories against the real, unredirected os.tmpdir(), with no cleanup. Some of the originally observed leak prefixes (help-bench, ime-lifecycle-state) came from exactly these lanes, so this isn't hypothetical.

Suggested approach

Same trick, applied at the npm-script level instead of via a test-runner hook, since node --test has no global setup/teardown concept:

  • A tiny wrapper script (or inline TMPDIR=$(mktemp -d) ...; rm -rf "$TMPDIR" in the relevant package.json scripts) that sets TMPDIR before invoking node --test, and does one recursive rm after it exits — mirroring scripts/vitest-tmpdir-global-setup.ts's /tmp-rooted approach (not nested inside macOS's deep per-user TMPDIR, to avoid the AF_UNIX sun_path-length issue that PR hit).
  • Extend (or duplicate) scripts/check-tmpdir-leaks.ts to also assert no leftover directory from these lanes.

Scoped out of #1593 to keep that PR focused; this is the ~10% of the leak surface it didn't close.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions