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

Watching network drive '\\server\folder' does not work #895

Closed
Zireael opened this issue Oct 6, 2019 · 20 comments · Fixed by #1025
Closed

Watching network drive '\\server\folder' does not work #895

Zireael opened this issue Oct 6, 2019 · 20 comments · Fixed by #1025

Comments

@Zireael
Copy link

Zireael commented Oct 6, 2019

Hi
I have a problem where chokidar does not report changes to network shared folder, i.e. \\\\file.server.net\\dev\\7500. Using fs.writeFile() on that folder works fine and a file gets created by Node. I'm under Win10.
My config is below. I tried both with usePolling true and false, no change.
I don't get any errors, just changes to network folder don't get reported. Watching a folder on local drive C:\db works fine. Watching that network drive using drive letter path format actually works too s:\\dev\\7500. I'd prefer to use server path notation in case drive mapping letters get changed in future, or some users in the company have different letters mapped.

Do you see anything amiss in my setup?

fs.writeFile('\\\\file.server.net\\dev\\7500\\test.txt', 'this file gets created OK', (err) => {
  if (err) throw err
})

const chokidarOptions = {
  persistent: true,
  // ignored: "*.txt",
  ignoreInitial: false,
  followSymlinks: true,
  cwd: ".", 
  disableGlobbing: false,
  usePolling: true, // tried with false as well
  interval: 1000,
  binaryInterval: 3000,
  alwaysStat: false,
  depth: 99,
  awaitWriteFinish: {
    stabilityThreshold: 2000,
    pollInterval: 100,
  },
  ignorePermissionErrors: true, // watch files that don't have read permissions
  atomic: true, // or a custom 'atomicity delay', in milliseconds (default 100)
};

const optionsFileMonitor = {
  watchFolders: ["\\\\file.server.net\\dev\\7500", "s:\\dev\\7500", "C:/db"]
};

const fileMonitor = chokidar
  .watch(optionsFileMonitor.watchFolders, chokidarOptions)
  .on("all", (event, epath) => {
    console.log(event, path.resolve(epath));
})
@puglisij
Copy link

puglisij commented Dec 6, 2019

I have the same issue watching a directory on a CIFS drive on Windows 10.
For example //cifs/foo/bar
I get no reported file changes. I DO get changes reported when using the native fs.watch()
It looks like there may be an issue with path normalization in chokidar?

@SutharMukesh
Copy link

I too had this problem
downgrading to chowkidar@3.1.1 solves for me.

@valdiss
Copy link

valdiss commented Jan 14, 2020

I have the exact same issue as Zireal, watching a folder on our network drive does not work on Windows 10.
I tried with fs.watch, it does work.

I downgraded to 3.1.1, it does not fix the issue.

@rpsirois
Copy link

Bump

@kreddys
Copy link

kreddys commented Jun 5, 2020

Changing to @3.1.1 worked for me

@jaredbaszler
Copy link

Changing to @3.1.1 worked for me as well. I was on 3.4.0 when it wasn't working.

@nicograef
Copy link

nicograef commented Jul 13, 2020

Changing to @3.1.1 worked for me as well. I was on 3.4.0 when it wasn't working.

+1 here 👋

@paulmillr What's the status for this issue? Thank you!

@paulmillr
Copy link
Owner

No status. Feel free to debug this and provide a pull req.

@whyboris
Copy link
Contributor

whyboris commented Jul 18, 2020

Confirming version 3.4.1 does not work on my network files on Windows (regardless of usePolling) :
\\StoragePC\DrivePool\Movies (I even tried //StoragePC/DrivePool/Movies just in case)
When pointing to this directory, chokidar does not find any files (even though they are there and are accessible using fs) 😢

If I Map network drive to M:\ for example -- it works 👀

@whyboris
Copy link
Contributor

whyboris commented Jul 18, 2020

I did some debugging, I think I see the issue:
https://github.com/paulmillr/chokidar/blob/master/index.js#L395
When the .add() happens, the first thing executed is let paths = unifyPaths(paths_);
unifyPaths eats the first / in the address, so:
\\StoragePC\DrivePool\Movies goes in (even //StoragePC/DrivePool/Movies works here)
and unifyPaths returns
/StoragePC/DrivePool/Movies ⚠️ (note the first / is removed) 👀
If / is not removed by the method, all the files are found without a problem 👌 (even usePolling can be false it seems 🤷 )

And here's the line that causes the trouble:
https://github.com/paulmillr/chokidar/blob/master/index.js#L102
in the toUnix method:

  while (str.match(DOUBLE_SLASH_RE)) {
    str = str.replace(DOUBLE_SLASH_RE, SLASH);
  }

Simply replaces the double slash with a single slash :trollface:

@whyboris
Copy link
Contributor

@paulmillr -- thank you for your excellent library 🙇

I feel like I've correctly identified where the problem happens (replacing double slashes with a single slash) ✅

I suspect one solution is to somehow ignore the double slashes if they occur as the first characters 🤔

I don't know what would be the best way to fix this without breaking something for everyone else.

I'm happy to make a PR if you suggest how I should handle it 😁 🤝 😄

@jaredbaszler
Copy link

Changing to @3.1.1 worked for me as well. I was on 3.4.0 when it wasn't working.

This worked for me to get it to listen to a network folder correctly. But then I eventually had to shut it off and reroute things to a local project folder. The reason being once I had this monitoring a network folder my database called with the OracleDB package slowed WAY down. Simple Select queries were taking around 10 seconds and once I changed Chokidar to monitor a network folder I got the queries back down to less than .1 seconds. I'm not sure why but just passing along my experience.

@whyboris
Copy link
Contributor

whyboris commented Aug 1, 2020

👋 @paulmillr -- please let me know if the solution I propose to this problem (see above) is acceptable, namely:

do not replace double slash // with single slash / if it occurs at the beginning of the string

I would like to create a PR, but wanted confirmation that this is an acceptable (mergeable) solution or if you prefer something else 🙇

@paulmillr
Copy link
Owner

@whyboris try doing this and see if tests fail on any platform

@whyboris
Copy link
Contributor

whyboris commented Aug 3, 2020

PR to solve the problem 🤞 #1025 😁

@jmeinke
Copy link

jmeinke commented Aug 6, 2020

@paulmillr I think this issue should not be closed while there is no new chokidar release available via npm that includes the fix provided by @whyboris. BTW: Thanks a lot for your work on chokidar 👍 🙏

@oumad
Copy link

oumad commented Apr 1, 2021

I'm still having this issue, I hope the PR that fixes it will be available in the next chokidar update

@whyboris
Copy link
Contributor

whyboris commented Apr 1, 2021

@oumad -- seems like the fix is available since release 3.4.2
https://github.com/paulmillr/chokidar/releases/tag/3.4.2
Have you tested?

@oumad
Copy link

oumad commented Apr 2, 2021

@oumad -- seems like the fix is available since release 3.4.2
https://github.com/paulmillr/chokidar/releases/tag/3.4.2
Have you tested?

Interesting, then I don't know why for some reason I get no event fired when I try watching a directory in this format \\server\path\to\folder\*.{extentions}
But no problem when I watch the same directory like this :
S:/path/to/folder/*.{extentions}
regardless of usePolling set to true or false.

Edit : I have been using the 3.4.1 version my bad ! For some reason I thought we already updated chokidar package in our app

@TierK
Copy link

TierK commented Dec 27, 2023

have the same issue with chokidar 3.5.3

In local folders, it works perfectly. But it doesn't work with remote folders with the same functions

Linux machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.