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

nodemon triggers restart when file is opened #1044

Open
abhishekgoenka opened this issue Nov 2, 2020 · 0 comments
Open

nodemon triggers restart when file is opened #1044

abhishekgoenka opened this issue Nov 2, 2020 · 0 comments

Comments

@abhishekgoenka
Copy link

Restarts are triggering just opening the files in an editor such as VSCode.

Steps to reproduce

Install node.
Install chokidar.
Create a js file and add the following code

const chokidar = require('chokidar');
chokidar.watch('C:\\code\\tools\\ui\\Utils').on('change', (event, path) => {
  console.log(event, path);
});

Open the tools folder in VSCode and just click in the file browser to open the file in the editor.
Soon as the file is opened, console.log statement gets executed. See below video

bug video.zip

Versions (please complete the following information):

  • Chokidar version: v3.4.3
  • Node version: v14.15.0
  • OS version: Windows 10

Ideally prove a problem by isolating and making it reproducible with a very short sample program, which you could paste here:

const chokidar = require('chokidar');

chokidar.watch('C:\\code\\MetaFXTools\\ui\\Utils').on('change', (event, path) => {
  console.log(event, path);
});

I have attached a video for reference. It works if I change the following condition

        if (!at || at <= mt || mt !== prevStats.mtimeMs) {
          this.fsw._emit(EV_CHANGE, file, newStats);
        }

to

        if (!at ||  mt !== prevStats.mtimeMs) {
          this.fsw._emit(EV_CHANGE, file, newStats);
        }

Expected behavior
console.log statement should be executed only if there is any change in the file.

Reference - It is the same issue that is described remy/nodemon#1208 here.

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

No branches or pull requests

2 participants