Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid uncaught exception when file is deleted (#3313)
If I run `snowpack dev` and then delete a watched file, the process crashes with this error: ⠸ watching for file changes...node:internal/process/promises:246 triggerUncaughtException(err, true /* fromPromise */); ^ [Error: ENOENT: no such file or directory, open '/home/ahupp/new-dir/src/index.js'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/ahupp/new-dir/src/index.js' } The root issue seems to be that 'unlink' events go through the same path as change/add events, which try to read the file and throw an uncaught exception. This diff moves the call to `prepareSingleFile` so that it only runs in the change and add paths. I'm not very familiar with this codebase so feel free to tell me this is the wrong approach, but it does fix the problem for me. This should fix #3252 Other issues to consider: * The stack trace for these exceptions seems to be lost, which makes debugging this more challenging than necessary. * Should exceptions from chokidar watch events be caught and logged?
- Loading branch information
45e2a22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: