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

ExternalEditWatcher displays incorrect status #1614

Closed
zsunberg opened this issue Jun 1, 2019 · 6 comments · Fixed by #1659

Comments

@zsunberg
Copy link

commented Jun 1, 2019

Operating system

  • Windows (?)
  • macOS (?)
  • Linux (tested)

Application

  • Desktop (tested)
  • Terminal (?)

Description

Sometimes when the external edit file is saved by a mainstream editor (like vim or emacs, and maybe even gedit), the ExternalEditWatcher loses track of the file via an unlink event (#710, #766, discourse). The external edit button still displays "Watching", but no new changes are detected.

Solution

I see several possible solutions

  1. Chokidar gets fixed to handle this upstream
  2. We change the ExternalEditWatcher so that it simply stops watching the file when this happens (if the user pushes the watch button again, then it seems like it will overwrite the file - yikes!)
  3. We change the ExternalEditWatcher code so that it recognizes when this has happened, displays an error, and allows the user to recover.
  4. We change the ExternalEditWatcher code to be robust to this failure mode and automatically rewatch the file.

Notes:

  • also need to provide documentation for workarounds (#710)
  • Relevant code for 2,3,4: 0a5ad1d

I'd be happy to take a shot at making a PR to fix this, but I have two questions:

  1. Which solution do we want to implement? 1, 2, 3, or 4?
  2. Where should I put tests for this problem? (I have never worked on a large js/electron project before)
@zsunberg

This comment has been minimized.

Copy link
Author

commented Jun 1, 2019

It might be hard to come up with a perfect fix for this, but it's not very nice to have the gui dishonestly say "Watching" when it is not.

@sciurius

This comment has been minimized.

Copy link

commented Jun 2, 2019

When using emacsclient you can avoid this by setting backup-by-copying to t in the server-switch-hook.

@laurent22

This comment has been minimized.

Copy link
Owner

commented Jun 9, 2019

I guess we should indeed show that it's no longer watching the file, but should also try to fix the bug. The issue is that it's hard to replicate.

@zsunberg

This comment has been minimized.

Copy link
Author

commented Jun 9, 2019

@laurent22

This comment has been minimized.

Copy link
Owner

commented Jun 15, 2019

Did you report this issue on the Chokidar repo?

On Windows, when I delete the file, then recreate it after a second I see it does this:

Event: add: C:\Users\USERNAME/.config/joplindev-desktop/edit-7318248e64154e56bfafc254fe89382a.md
Event: change: C:\Users\USERNAME/.config/joplindev-desktop/edit-7318248e64154e56bfafc254fe89382a.md
Event: unlink: C:\Users\USERNAME\.config\joplindev-desktop\edit-7318248e64154e56bfafc254fe89382a.md
Event: change: C:\Users\USERNAME/.config/joplindev-desktop/edit-7318248e64154e56bfafc254fe89382a.md
Event: add: C:\Users\USERNAME\.config\joplindev-desktop\edit-7318248e64154e56bfafc254fe89382a.md

So it seems to add the file back automatically, or maybe it never actually stops watching it. That behaviour seems to happen too on Linux but just not all the time, so it could be something to fix on the Chokidar package.

@zsunberg

This comment has been minimized.

Copy link
Author

commented Jun 18, 2019

Hi @laurent22, no, I did not file on chokidar because I didn't have time to figure out if it was a previously reported issue, though I agree that the root problem should be fixed there or even further upstream (that's why this issue has a title about the UI displaying incorrect status).

On Windows, when I delete the file, then recreate it after a second I see it does this

Yeah, I think it might happen more often when the delay is shorter - like a few ms. See also paulmillr/chokidar#35 (comment).

I'll try to look at #1659 sometime in the next few days and see if it fixes it for me.

@lock lock bot locked and limited conversation to collaborators Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.