Skip to content

Dependency optimizer recreates cache directories after server.close() resolves (Vite 8.1.2 / 8.3.4) #23752

Description

@raskum1984

Dependency optimizer recreates cache directories after server.close() resolves — Vite 8.1.2 and 8.3.4

Reproduction

https://gist.github.com/raskum1984/dc5bacb0a0f9ff804236e7e0cbc12966

Download/clone all nine files, then follow README.md:

node setup.mjs
npm ci --prefix baseline
npm ci --prefix candidate
node run.mjs baseline
node run.mjs candidate

Expected behavior

After await server.close() resolves, and a test-owned cache directory has been
removed, Vite should not recreate optimizer output inside that directory.

Actual behavior

Two concurrent middleware-mode Vite servers use independent caches. Both Vite
8.1.2 and 8.3.4 successfully load a simple React SSR module and resolve their
original close() calls. Each owned cache is then removed successfully; the
child logs an empty cache-root snapshot. The child exits naturally with code 0.

Inspection by the parent after child exit finds recreated server-*/deps_temp_*
directories containing react.js, react-dom_server.js, sourcemaps and Rolldown
runtime output. The parent exits 1 to report this lifecycle failure; it does not
force child termination or suppress an error.

This occurred in three earlier isolated runs per version, affecting six caches
per version, and in two further public-reproduction checks per version,
including a check after installation using npm ci.

Environment

  • macOS ARM64
  • Node.js 24.21.0
  • npm 11.19.0
  • Baseline: Vite 8.1.2, Rolldown 1.1.3, Darwin ARM64 binding 1.1.3
  • Candidate: Vite 8.3.4, normal transitive Rolldown 1.2.13, binding 1.2.13
  • React and react-dom 19.2.7

Additional context

An original larger test suite intermittently experienced ENOTEMPTY during
test-owned cache removal after Vite's original close() resolved. Separate
native worker crashes were observed, but their connection to this lifecycle is
unconfirmed. This minimal reproduction demonstrates late cache output; it does
not itself reproduce the original ENOTEMPTY or native crash.

There are no sleeps, cleanup retries, shared cache, optimizer disabling or
concurrency reduction. Each attempt has a fresh cache root and child process.
The reproduction contains only synthetic code and locked dependencies, with no
application configuration, credentials or external service access.

Activity

  1. added theissue type on Oct 14, 2026
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

    feat: deps optimizerDependencies Optimizationp1-choreDoesn't change code behavior (priority)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions