deno
e805fcd6 - fix(ext/node): emit 'error' event for fs.watch open failures (#34398)

Commit
88 days ago
fix(ext/node): emit 'error' event for fs.watch open failures (#34398) `fs.watch` was throwing `Deno.errors.NotFound` synchronously when the underlying inotify/FSEvents watch couldn't be added — most commonly when an editor's atomic-save renamed its temp file away before the watch was installed. EventEmitter-style consumers like chokidar (and vite, which bundles it) expect a Node-style ENOENT delivered via the watcher's `'error'` event, so the synchronous throw surfaced as an uncatchable rejection inside vite's async file handler. The fix wraps the `Deno.watchFs` call, converts `NotFound` to a Node-style ENOENT `uvException` (the notify crate's error message lacks the `(os error N)` suffix that `denoErrorToNodeError` parses, so we detect it by class), and emits it on the returned `FSWatcher` via `process.nextTick` so listeners attached after `watch()` returns can handle it. Fixes #34396
Author
Parents
Loading