Skip to content
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

Watcher: changes from git operations are reported as add and not change #136460

Closed
moloko opened this issue Nov 4, 2021 · 14 comments
Closed

Watcher: changes from git operations are reported as add and not change #136460

moloko opened this issue Nov 4, 2021 · 14 comments
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member file-watcher File watcher insiders-released Patch has been released in VS Code Insiders macos Issues with VS Code on MAC/OS X upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream verified Verification succeeded
Milestone

Comments

@moloko
Copy link

moloko commented Nov 4, 2021

This is basically the same issue as #134851 but I can't re-open that so creating a new issue

There are full details of the problem here: teledemic/vscode-branch-warning#15 (most of the specifics are in this comment) hope it's OK to link to that rather than reproduce here...

@bpasero bpasero self-assigned this Nov 4, 2021
@bpasero bpasero added the file-watcher File watcher label Nov 4, 2021
@bpasero
Copy link
Member

bpasero commented Nov 4, 2021

@moloko can you please configure files.legacyWatcher: off, restart, make sure you use Code stable 1.62.0 (which we just released) or latest insider and let me know if it still reproduces. Also let me know platform you are on when seeing the issue.

@bpasero bpasero added the info-needed Issue requires more information from poster label Nov 4, 2021
@bpasero bpasero added this to the November 2021 milestone Nov 4, 2021
@moloko
Copy link
Author

moloko commented Nov 4, 2021

@bpasero Yes I still have the issue on VSC v1.62.0 with files.legacyWatcher: off

I am running macOS v11.6.1 on an M1 Macbook Pro - but also get the same issue on my old Intel Mac (same OS version)

I'll try the Insider build tomorrow if I can

Version: 1.62.0
Commit: b3318bc
Date: 2021-11-03T15:23:13.307Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 20.6.0

@bpasero
Copy link
Member

bpasero commented Nov 5, 2021

@moloko please do. I just gave it a test:

  • run code-insiders --verbose
  • open developer tools (from Help menu)
  • in the console filter by typing .git/HEAD
  • switch a branch in the project
  • see how the event is triggered from the file watcher:

image

@bpasero
Copy link
Member

bpasero commented Nov 5, 2021

Ok, I see a difference in events:

  • chokidar: reports CHANGED
  • vscode-nsfw: reports ADDED
  • parcel/watcher: reports ADDED

We used chokidar previously when you open a folder. We always have been using vscode-nsfw when you open a multi-root workspace with more than 1 folder. We now use parcel/watcher.

I am not surprised that vscode-nsfw and parcel/watcher report the same kind of event because their implementation is very similar. It is possible that chokidar was doing some kind of normalization that would make it report a change instead of add.

One workaround for your extension would be to handle this case too, not just the changed case.

I would still have to figure out if the file is actually deleted and added on disk or changed.

@bpasero bpasero changed the title New file system watcher not reporting changes to /.git/HEAD file macOS: changes to /.git/HEAD are reported as add and not change Nov 5, 2021
@bpasero bpasero added confirmed Issue has been confirmed by VS Code Team member macos Issues with VS Code on MAC/OS X and removed info-needed Issue requires more information from poster labels Nov 5, 2021
@bpasero bpasero changed the title macOS: changes to /.git/HEAD are reported as add and not change macOS: changes to /.git/HEAD are reported as add and not change Nov 5, 2021
@bpasero bpasero changed the title macOS: changes to /.git/HEAD are reported as add and not change macOS: changes to .git/HEAD are reported as add and not change Nov 5, 2021
@moloko
Copy link
Author

moloko commented Nov 5, 2021

One workaround for your extension would be to handle this case too, not just the changed case.

Cool, though I'm not actually the author of that extension, that'd be @teledemic

@bpasero bpasero added upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream bug Issue identified by VS Code Team member as probable bug labels Nov 6, 2021
@bpasero
Copy link
Member

bpasero commented Nov 6, 2021

This is actually parcel-bundler/watcher#72 which I had been reporting before. At the moment the only workaround is to react to any change kind for this file to detect a branch switch.

@bpasero bpasero changed the title macOS: changes to .git/HEAD are reported as add and not change Watcher: changes to .git/HEAD are reported as add and not change Nov 6, 2021
@bpasero
Copy link
Member

bpasero commented Nov 18, 2021

I am going ahead to close this, I am not sure if my PR will be accepted but the workaround is to update downstream consumers to also listen to add events.

@bpasero bpasero closed this as completed Nov 18, 2021
@bpasero bpasero removed this from the November 2021 milestone Nov 18, 2021
@bpasero bpasero changed the title Watcher: changes to .git/HEAD are reported as add and not change Watcher: changes from git operations are reported as add and not change Nov 23, 2021
@bpasero bpasero added this to the November 2021 milestone Nov 23, 2021
@bpasero
Copy link
Member

bpasero commented Nov 23, 2021

Reopening for tracking.

@bpasero bpasero reopened this Nov 23, 2021
guibber pushed a commit to guibber/vscode that referenced this issue Nov 30, 2021
@bpasero bpasero added the author-verification-requested Issues potentially verifiable by issue author label Nov 30, 2021
@moloko
Copy link
Author

moloko commented Nov 30, 2021

Doesn't look like it has helped I'm afraid, same issue as before.

I'm using:
Version: 1.63.0-insider (Universal)
Commit: b9cf83f
Date: 2021-11-30T05:13:11.628Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 20.6.0

@bpasero
Copy link
Member

bpasero commented Nov 30, 2021

Thanks for trying, it was working for me though in my simple example where I switched a branch that changes a single file.

@moloko
Copy link
Author

moloko commented Nov 30, 2021

@bpasero weirdly even enabling the 'legacy watcher' now no longer works for me, in both Insider build and v1.62.3 (I think it stopped working a few weeks back).

If I amend Teledemic's extension to have a handler for onDidCreate it works fine both with and without legacy watcher enabled.

@bpasero
Copy link
Member

bpasero commented Nov 30, 2021

Yeah it is always best as an extension to react to both create and change events because there is no 100% guarantee.

@roblourens
Copy link
Member

Not sure there is anything to verify here, and I assume you don't want to reopen the issue?

@roblourens roblourens added the verified Verification succeeded label Dec 3, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2022
lemanschik pushed a commit to code-oss-dev/code that referenced this issue Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member file-watcher File watcher insiders-released Patch has been released in VS Code Insiders macos Issues with VS Code on MAC/OS X upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants
@roblourens @bpasero @moloko and others