-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
File watcher problems on Mac #210422
Comments
👋 thanks for reaching out on this issue. Yes, VS Code is using a 3rd party file watcher (https://github.com/parcel-bundler/watcher) that in the end will utilise We do have some code in place to restart the watcher process if it happens to crash, but that is limited to a few times. I suggest to start with providing the logs of VS Code, to see if the crash is reported in there. We have a command to open the logs folder for the current session: If you go up 2 levels, it would be a Thanks! |
What happened to chokidar? Was it replaced by parcel? |
Yes, already a long time ago, parcel replaced our 2 solutions (chokidar, nsfw). |
Hi @bpasero, I'm not much further, but I noticed something. I believe this also doesn't normally happening, but it started happening just now. (Still on Mac.) I have a file ( |
@gvanrossum we do have logic in place to automatically reload the opened buffers as well as the file explorer when focus moves into the VS Code application, assuming that files might have changed as a result of the user using another application. When you are in the state that a file does not refresh when its changed from the terminal, can you do this:
See if you get events reported for when |
Also, when I try to edit the file in the buffer (before forcing a sync by going to another app and back) it refuses to do so, popping up an error box saying "Failed to save 'Makefile': The content of the file is newer." (Etc. -- I can send a screenshot but I imagine you know what error box I'm talking about and it's complicated for me to send screenshots here, as I don't have access to this tracker from the Mac where it's happening.) |
@gvanrossum sorry I forgot that the file watcher channel is something we only introduced in April and is not yet released to stable. With your version (which I assume is As for the error you see when saving: that actually makes sense, given the issue at hand. When you save a buffer in VS Code we do a quick check if the file has changed on disk by comparing the To workaround this issue for now, it should be sufficient for you to close all instances of the buffer in VS Code and open it again and then try to make changes and save it. Re-opening the buffer should make sure to fetch latest from disk. Please then see if after saving there is anything logged to the "Window" output channel. It would contain a lot more than just file event related entries so please just send me the logs or copy it here. Thanks! |
Okay, here's the log file. Ignore the events for files other than |
@gvanrossum interesting, so this seems relevant:
So our file watcher does detect the change, but decides to ignore it due to some rules that are in place for this watcher. When this happens, are you in a VS Code window with a folder opened or is it an empty VS Code instance? And if a folder is opened, would that be I am curious how you end up with a watcher that is configured with this include rule because I think there is a bug in there. I suspect that it might be an extension that installs a file watcher (we have extension API for that) that triggers this (for example the Python extension itself). For that to confirm it would be helpful to:
This would include information about how file watchers are setup initially 🙏 |
The VS Code window is open on the Here's the log you asked for: |
(Did you want the output from the Terminal window where I started |
Thank you, that is the log that is helpful:
This is a full, recursive, file watcher that uses macOS Curious how you make changes to And then, if you could share me with a list of the extensions you have installed, then I can try to simulate in a similar setup on my machine to see if it reproduces for me. |
The Makefile is written by a script that does How do I send you the list of extensions? Does it help to know that this is an M3 Mac (so, ARM architecture)? There is still something unexplained going on. I just quit VS Code using cmd-Q and then restarted it, and now all is well. Just before I did that, I learned that the problem is not limited to files mentioned in I think that earlier today as I was experimenting, I may have closed the VS Code window, but there might have been another window open, or there may have been a window-less "Application" instance still running -- I noticed that at some point I had a VS Code app with a truncated menu and no open windows. In any case I suspect it won't be easy to reproduce this. :-( |
We miss a direct command to do so I believe, but here is what works easily:
I think that should not make much of a difference, most of our team is using ARM by now and many of our users are likely as well.
Yeah, the fact that this issue does not reproduce after a clean restart will probably make it hard for me to reproduce easily. It seems to happen only after some time of usage. Its interesting that this also reproduces using
We do reserve 1 file watcher process per opened window, so in theory they should all be isolated from each other. If you close a window and open it again - even if VS Code was still running without window - you should see a fresh file watcher being created. The same is true for when you reload the active window ("Developer: Reload Window" in the command palette). Once I get the list of extensions, I will investigate if any of your extensions triggers creation of file watchers, it may still be related. |
Okay, here are my extensions. Sorry about the formatting, I had to copy/paste between computers via a GMail draft. copilot Git 1.186.0
I believe it -- and yet, I feel that the thing was reproducible across window close/reopen (e.g. you asked me to start from the command line using It hasn't come back yet -- alas, it may be several weeks before I see it again. Will keep you posted! |
Thanks, I now have a VS Code profile with the same set of extensions and the same repository (https://github.com/python/cpython) cloned to my user home folder. I can see the same output you reported, for when the buffer properly updates:
(the line So at one point, for you, for some reason, the @gvanrossum curious, when this happens, are all buffers refusing to update when changes are made from the integrated terminal (for example change another file using VI from integrated terminal). Or is it really only the top level |
It's all files, AFAICT. I've definitely seen it happen to other files, files that were under git control. I think once it starts happening it happens to every buffer in ever window. |
Got it. Btw the I am not sure this would help in your case, but configuring this setting may improve things and reduce load from file watching in general for this folder in VS Code. |
I am happy with the performance of the watcher except for the state where it enters this buggy state. I'd rather help you track down what gets it in that state than configure a workaround. |
This comment was marked as duplicate.
This comment was marked as duplicate.
I was having a similar issue, would get no refreshing at all, ever, unless I left the VSCode window and came back in. This issue helped to some degree. While I had no errors showing up in my trace logs for File Watcher, I did start adding some git-ignored directories to my I was able to reproduce easily by |
Occasionally VS Code on Mac gets in a state for me where the mechanism used to update edit buffers when the on-disk file is modified stops working. The problem applies to all files, and it doesn't matter whether I have previously edited the file or not.
What I expect:
What I see (once in this state):
Once it is in this state it remains broken until I close and reopen the workspace.
I presume you are using some kind of file watcher daemon and the daemon dies. Maybe you can direct me to a window where I can find the logs to help you further debug this?
I don't know what triggers this -- I only observe it when I do a command line git operation like
git checkout <file>
that changes a file on disk.I have auto-save on with a 100 msec delay.
I should mention that the workspace I tend to use (almost exclusively) is my checkout of the cpython repo, which is fairly large but not excessively so (5000 files under git control, and I have over 25,000 files total in that repo). My home directory is, let me say, rather much larger.
This is a Mac M3 running macOS Sonoma 14.4.1. In case it matters for the watcher, I am using a Dropbox client.
I'll gladly provide more information if you have subsequent questions, but it may take days before the problem pops up again.
The text was updated successfully, but these errors were encountered: