This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #517.
This was a fun one to investigate. The bug, at its core, was the fact that different editors have different approaches to saving files--some, like vim, actually delete and re-create an entire file when saving its contents. Different file notification APIs across different operating systems track changes to files differently; in the case of the Linux file watcher in the notify crate (inotify) this watcher will stop watching a file once it has been deleted; vim deletes files regularly when saving new contents (https://unix.stackexchange.com/questions/188873/using-inotifywait-along-with-vim).
I wasn't familiar with the live preview code, so I spent time reading through it. Ultimately I couldn't find any bugs that could cause the behavior I observed. Something we noticed was that webpack workers watch directories and worked just fine with vim, implying that watching a directory for javascript workers would also work (inotify would continue to watch the index.js file even if vim deleted and re-created it).
This PR may also need to be replicated for #522, given that the Rust live preview service also watches an individual javascript file.
This PR also reduces noisy output by the live preview service. Notifying over directories produced a large amount of repeated
"Detected change during cooldown..."
terminal output.