Vite createServer() Leaks File Watcher When configureServer or buildStart Throws
- Investigating(current)
- Trending(upcoming)
- Workaround available(upcoming)
- Resolved(upcoming)
Executive summary
Vite's createServer() keeps its file watcher open when a plugin throws an error in configureServer or buildStart, preventing the Node.js process from exiting. This occurs because the watcher is already active when these lifecycle hooks run, unlike config or configResolved hooks.
No verified workaround yet
None of the linked reports describe a mitigation. Follow this incident to hear when one appears.
Official fixThe file watcher is initialized and left open before the configureServer and buildStart hooks execute, causing resource leaks and hanging processes when those hooks throw an exception.
Evidence
1 report · 1 GitHubShow
- [1]GitHub First report`createServer()` keeps its file watcher open when `configureServer` or `buildStart` throws(opens GitHub issue in a new tab)
Describe the bug My CLI starts a Vite dev server through the JS API. When a user's plugin threw in configureServer, the CLI printed the error and then just sat there. createServer() had rejected, but its file watcher was still open (and with @cloudflare/vite-plugin, workerd too), so the process never exited. The same happens when a plugin throws in buildStart. A throw from config or configResolved exits fine. Looks like those run before the watcher starts. With server.watch: null all four…
by materwelonDhruv 0upvotes 7comments
Timeline
- First report on GitHub issue
`createServer()` keeps its file watcher open when `configureServer` or `buildStart` throws
Source