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

onDidChange is called once #108

Closed
maximeallanic opened this issue Apr 25, 2020 · 9 comments · Fixed by #143
Closed

onDidChange is called once #108

maximeallanic opened this issue Apr 25, 2020 · 9 comments · Fixed by #143

Comments

@maximeallanic
Copy link

Replace fs.watch to fs.watchFile in _watch method.

@dancon
Copy link

dancon commented Jun 21, 2020

It indeed is called once, and fs.watchFile works as expected as @maximeallanic said, so,is there any plan to fix the issue? @sindresorhus

@sindresorhus
Copy link
Owner

What Node.js version and operating system?

@sindresorhus
Copy link
Owner

fs.watch was an intentional choice. If it doesn't work, I recommend opening an issue on Node.js instead.

From the Node.js docs:

Using fs.watch() is more efficient than fs.watchFile and fs.unwatchFile. fs.watch should be used instead of fs.watchFile and fs.unwatchFile when possible.

@sindresorhus
Copy link
Owner

// @yaodingyd

@brpaz
Copy link

brpaz commented Jun 21, 2020

Have the same issue. the onDidChange is only called the first time I change the file config file.

Node v12.16.3 and Fedora 32

@dancon
Copy link

dancon commented Jun 21, 2020

MacOS 10.15.5 and Node 12.6.3

@yaodingyd
Copy link
Contributor

I can't reproduce this on my machine. macOS: 10.14.6 node: 12.4.0

@adlerluiz
Copy link

adlerluiz commented Aug 25, 2020

Windows 10:

  • node: 12.18.3
    • fs.watch - Ok
    • fs.watchFile - Ok (+- 1s delay)

Ubuntu 20.04:

  • node 12.18.3
    • fs.watch - Fail (once)
    • fs.watchFile - Ok

Mac:

  • I don't have = (

as said by @sindresorhus seems to be a nodejs problem.

There are several issues about this case such as:

I suggest two workarounds:

  1. Implementation of https://github.com/paulmillr/chokidar
  2. Add { watchFile: true | false } like { watch: true | false }

@sindresorhus
Copy link
Owner

@adlerluiz Can you check the latest Node.js 15 version? Would be useful to see if that improves the situation. (We'll still need to work around for Node.js 12)

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

Successfully merging a pull request may close this issue.

6 participants