Fix not rebuilding files when rename
event is emit
#9689
Merged
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.
Presently when certain editors "atomically" change files, the CLI watcher fails to rebuild for them. This happens to me when using Vim, as by default it's behaving as if
backupcopy
is set tono
. However the default value isauto
which means Vim autodetects the system and chooses whichever strategy it deems optimal, so I am replicating the issue with an explicit config file:Now when editing files, following inotify events are triggered:
Adding a console.log in the raw event handler, we can see chokider is emitting rename followed by change events:
So the file change notification is picked by Tailwind, but no rebuild actually happens.
In my testing, when rename event handler is calling recordChangedFile from inside promise, then down the stack when
rebuild
is called, the chain promise is already at a pending state, and this condition is never fulfilled, sorebuild()
is never called. I think might be the bug why rebuild doesn't occur in Visual Studio too as per #9667.Additionally for atomic writes, the change is preceded by rename so a rebuild is already queued. It would end up happening twice, so a guard during the check could avoid that.