buildStart
behavior change in Vite 6 can cause vite optimize
to hang
#19316
Labels
buildStart
behavior change in Vite 6 can cause vite optimize
to hang
#19316
Describe the bug
Under Vite 5, a plugin's
buildStart
doesn't run duringvite optimize
.Under Vite 6 it does, as a side-effect of
environment.init()
being introduced inoptimizeDeps()
.And since
vite optimize
rather confusingly usescommand === 'serve'
here, plugins now have no way of knowing whether theirbuildStart
is running invite dev
vsvite optimize
.As a result, plugins that want to manage a dev-time background task will launch that task during
vite optimize
and can cause node to refuse to exit, since they think they are supposed to keep serving content.Reproduction
https://stackblitz.com/edit/vitejs-vite-ncfab2z9?file=vite.config.js
Steps to reproduce
The linked stackbliz has a minimal reproduction. Run
vite optimize
and observe that the process refuses to exit.You can repeat the same vite.config.js on Vite 5.x and observe that
vite optimize
no longer hangs.System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: