Skip to content

fix(server): handle file watcher errors without crashing - #23503

Open
kingmakeruix wants to merge 3 commits into
vitejs:mainfrom
kingmakeruix:fix/watcher-error-no-crash
Open

kingmakeruix wants to merge 3 commits into
vitejs:mainfrom
kingmakeruix:fix/watcher-error-no-crash

Conversation

@kingmakeruix

Copy link
Copy Markdown

What Log chokidar watcher errors as a warning instead of letting the uncaught error event crash the dev server. ## Why createServer subscribes to change/add/unlink but never error, so any watcher failure (e.g. EBUSY on a briefly locked file on Windows) kills vite dev. Closes #23470. ## How - Added watcher.on(error) in _createServer that warns via config.logger - Added regression test in packages/vite/src/node/tests/plugins/hooks.spec.ts ## Checklist - [x] Tests pass locally (hooks.spec.ts 25/25; new test fails without the fix) - [x] lint clean Note: prepared with AI assistance under my direction.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev server crashes the whole process when the file watcher emits an error (uncaught 'error' event, e.g. EBUSY on Windows)

1 participant