-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildStart
behavior change in Vite 6 can cause vite optimize
to hang
#19316
Comments
This is not fixed. Please run the original stackblitz reproduction against Vite main or 6.1.0-beta.2. You'll see it still hangs. |
IMO, an alternative solution that would be less disruptive would be to change the |
@ef4 would you give more context on why you are using |
The reproduction passes with #19356: you can check using the preview package for the PR: https://pkg.pr.new/vite@19356 |
I would be happy to drop
Is there a way to either (1) force the entire build to fail if there are build errors during dep optimization or (2) register a handler for the errors themselves so we can detect them? |
would you provide a reproduction where |
Here is an example: https://stackblitz.com/edit/vitejs-vite-tb94xq8d?file=vite.config.js The exception is logged to the console, but vite continues on and serves the app despite the unhandled exception during dep optimization. |
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: