haskell-fswatch / hfsnotify

Unified Haskell interface for basic file system notifications
BSD 3-Clause "New" or "Revised" License
136 stars 40 forks source link

Debounce config works in very unexpected way (only on Win32) #95

Closed turboMaCk closed 3 years ago

turboMaCk commented 4 years ago

First of all thanks for providing this useful library. I appreciate all the work that must have gone into providing unified API which works on top of so widely different back-ends provided by different operating systems.

Description

However I've found the way the configuration works very confusing. Especially in how the Debounce configuration is handled. According to my findings this option is compatible only with Win32 backend where it's being used via newDebouncePayload call. Anyway documentation doesn't seem to mention that this option is specific to Windows backend. I find this especially confusing given many users may use Windows on their dev machine while deploying to Linux based production system.

SSCCE / Example

I can hardly navigate Windows operating system but I managed to somehow settuped VM to confirm debounce configuration indeed has some effect in Window. Using this demo project* I can confirm the incredibly high debouce value has no effect on Linux (inotify) while it does have an expected effect in Windows VM.

I think there are 2 potential solutions with widely different scope:

  1. Making sure documentation clearly states that Debounce is windows specific setting
  2. Porting debounce functionality to Linux and MacOS backends

Are my findings correct or did I made any mistake, missed some important piece of documentation or misunderstood something?


) I have no idea how to install version of ghc I want to on Windows so I had to remove versions constrains. Also I was able to compile project exactly once, the second attempt to compile the project on Windows didn't work because of combination of linker issue and permission issue when running cabal clean. Windows are too hard for me. I might have messed up something but quite frankly I have no idea how stuff suppose to work on windows at all, sorry.*

thomasjm commented 3 years ago

Hi @turboMaCk, sorry for the delay. You should be able to enable polling on any OS. Your main problem is that you're not setting confUsePolling = True in the watch config. Without this setting, it doesn't matter how big a confDebounce value you use because it will try to use the OS-specific watching mechanisms.

However, if it can't run the OS-specific watchers, it will fall back to polling. I'm not sure why you're seeing a discrepancy on Windows but my best guess is you're getting polling as a fallback.

I'm working on a new version of this library that will improve the situation in a few ways:

I'm going to close this issue but feel free to comment back with any questions.