-
Notifications
You must be signed in to change notification settings - Fork 109
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
Handle ENOENT
When Fingerprinting Deleted Files
#991
Handle ENOENT
When Fingerprinting Deleted Files
#991
Conversation
It's possible for files to be deleted between the time they are globbed and fingerprinted. When this happens we should catch the error and keep going rather than crashing.
Could you take a look here @rictic? (You merged my last PR, sorry for the ping) |
What about you @aomarks, would you be able to take a look at this? |
Thanks for this PR! I agree we should do something here since it shouldn't crash. However, I think that ignoring the files that got deleted during this race window might not be the best answer, because in general a file getting deleted in that window means there could be a problem with the configuration/setup that's going to cause wireit to get confused later on too. In this case, it sounds like you have a separate script which is independently writing to the same output files as the wireit script you are watching. I think we should probably invalidate the fingerprint somehow, so that the next time this script is invoked, a full build is forced. |
My first pass at this digested an empty file content so that successive builds without the file in the glob would have a different fingerprint. I went with this approach instead because it felt like a deleted output file would be something considered as part of the build output, however, I can see how that could be potentially problematic. It's probably better to err on the side of caution and ensure the cache is always valid instead of trying to avoid a rebuild that might have actually been necessary. |
I took a look at two possible approaches to fingerprinting in this case @aomarks:
The issue here is that, clearly, any assumption we make here is akin to undefined behavior. If we're trying to be safe then it's probably better to not cache anything at all. It makes more sense to fail the execution and convert the exception into an error result so that |
Yeah, that sounds like probably the thing to do. This also means that subsequent scripts that depend on this one won't be able to run -- which sounds correct. The build is likely in an invalid state after this race condition has been detected, so basically stopping execution at that node in the graph makes sense to me. |
Rather than trying to make some assumptions about what we should fingerprint, we will instead return an error. This makes sure we don't put the cache in an invalid state.
How about this @aomarks? |
This looks great! (This is a tricky one to test because it's hard to reproduce the situation. We'd need to have some tests where we sub in an |
I tested it out locally by breaking the Would you mind releasing a new version of |
BTW @ObliviousHarmony you should join our Discord if you're not already there! Good place for brainstorming and faster discussion iteration. https://discord.gg/chmdAwvq4e |
Nice! Yeah, that sounds fine. It would be quite a lot of work to test this properly and probably not worth it right now.
I did just release |
While computing the fingerprint there is a gap between input file globbing and fingerprinting wherein a file might have been deleted. This causes the hash building process to throw an exception and crashes the
--watch
operation. We ran into this problem while pairing awireit
script's--watch
option withwebpack --watch
. When Webpack started replacing files it would sometimes cause thewireit
script to stop the watch process.This pull request adds some error handling to this process so that
wireit
will continue working in this case.