Skip to content
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

Open
7 tasks done
ef4 opened this issue Jan 29, 2025 · 0 comments
Open
7 tasks done

buildStart behavior change in Vite 6 can cause vite optimize to hang #19316

ef4 opened this issue Jan 29, 2025 · 0 comments

Comments

@ef4
Copy link

ef4 commented Jan 29, 2025

Describe the bug

Under Vite 5, a plugin's buildStart doesn't run during vite optimize.

Under Vite 6 it does, as a side-effect of environment.init() being introduced in optimizeDeps().

And since vite optimize rather confusingly uses command === 'serve' here, plugins now have no way of knowing whether their buildStart is running in vite dev vs vite 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

N/A

Used Package Manager

pnpm

Logs

No response

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant