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

Restarts for non watched files #1320

Closed
mrchief opened this issue Apr 19, 2018 · 21 comments · Fixed by #1384 · 4 remaining pull requests
Closed

Restarts for non watched files #1320

mrchief opened this issue Apr 19, 2018 · 21 comments · Fixed by #1384 · 4 remaining pull requests

Comments

@mrchief
Copy link

mrchief commented Apr 19, 2018

  • nodemon -v: 1.17.3
  • node -v: 8.9.4
  • Operating system/terminal environment: Win 7 x64
  • Command you ran: nodemon index.js --inspect --exec babel-node

nodemon.json

{
  "delay": "2500",
  "watch": [
    "index.js",
    "tools/webpack/",
    "!tools/webpack/webpack.server.babel.js",
    "src/server.js",
    "src/utils/Html.js"
  ]
}

Expected behaviour

Nodemon should not restart if the files being watched have not changed

Actual behaviour

Nodemon restarts arbitrarily

Steps to reproduce

I'm using hot reload to watch/reload for client side file changes (which are other files in src folder) and nodemon to restart the process when only those files listed in the config changes.

This worked fine in 1.15.0.

However, starting few days back, I started seeing same errors as #1259 (been using this setup without issues for last 6 months). I saw the fix and decided to upgrade. Now with current version, nodemon is restarting more often. #1260 seems like a suspect but I'm not sure.

You can use create-react-app along with the provided nodemon.json to reproduce this. Doesn't happen consistently but happens frequently enough.


If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.


node: v8.9.4
nodemon: 1.17.3
command: C:\Program Files (x86)\Nodist\v-x64\8.9.4\node.exe D:\git\myapp\node_modules\nodemon\bin\nodemon.js index.js --inspect --dump --exec babel-node
cwd: D:\git\myapp
OS: win32 x64
--------------
{ run: false,
  system: { cwd: 'D:\\git\\myapp' },
  required: false,
  dirs:
   [ 'D:\\git\\myapp\\index.js',
     'D:\\git\\myapp\\tools\\webpack',
     'D:\\git\\myapp\\src\\server.js',
     'D:\\git\\myapp\\src\\utils\\Html.js' ],
  timeout: 1000,
  options:
   { dump: true,
     exec: 'babel-node',
     delay: '2500',
     watch:
      [ 'index.js',
        'tools/webpack/',
        '!tools/webpack/webpack.server.babel.js',
        'src/server.js',
        'src/utils/Html.js',
        re: /index\.js|tools\/webpack\/|!tools\/webpack\/webpack\.server\.babel\.js|src\/server\.js|src\/utils\/Html\.js/ ],
     ignore:
      [ '**/.git/**',
        '**/.nyc_output/**',
        '**/.sass-cache/**',
        '**/bower_components/**',
        '**/coverage/**',
        '**/node_modules/**',
        re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/ ],
     ignoreRoot:
      [ '**/.git/**',
        '**/.nyc_output/**',
        '**/.sass-cache/**',
        '**/bower_components/**',
        '**/coverage/**',
        '**/node_modules/**' ],
     restartable: 'rs',
     colours: true,
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     runOnChangeOnly: false,
     verbose: false,
     signal: 'SIGUSR2',
     stdout: true,
     watchOptions: {},
     execOptions:
      { script: 'index.js',
        exec: 'babel-node',
        args: [ '--inspect' ],
        scriptPosition: 0,
        nodeArgs: undefined,
        execArgs: [],
        ext: 'js,mjs,json',
        env: {} },
     monitor:
      [ 'index.js',
        'D:\\git\\myapp\\tools\\webpack/**/*',
        '!tools/webpack/webpack.server.babel.js',
        'src/server.js',
        'src/utils/Html.js',
        '!**/.git/**',
        '!**/.nyc_output/**',
        '!**/.sass-cache/**',
        '!**/bower_components/**',
        '!**/coverage/**',
        '!**/node_modules/**' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [ 'D:\\git\\myapp\\nodemon.json' ],
  watchInterval: null,
  signal: 'SIGUSR2',
  command:
   { raw: { executable: 'babel-node', args: [ 'index.js', '--inspect' ] },
     string: 'babel-node index.js --inspect' } }
--------------
@stale
Copy link

stale bot commented May 3, 2018

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label May 3, 2018
@mrchief
Copy link
Author

mrchief commented May 3, 2018

Dummy reply to keep this active

@stale stale bot removed the stale no activity for 2 weeks label May 3, 2018
@baileyandy
Copy link

I am seeing this issue too.

nodemon -v: 1.17.4
node -v: 10.1.0
Operating system/terminal environment: OSX 10.13.x
Command you ran: DEBUG=nodemon nodemon server/index.js
nodemon.json contents:

{
  "verbose": true,
  "watch": [
    "assets/",
    "server/",
    "app.js"
  ]
}

I am only specifically watching 2 directories and 1 file in the root of the project directory but nodemon is watching the entire project directory still. This only occurs when I add the file; watching 2 directories is working as expected.

After some digging, I found the code is specifically removing the file part. The comment suggests it is because of Windows but on OSX this causes the project directory to be watched.

I agree that #1259 and #1260 are the cause and specifically 1cda8fa. Reverting to 1.15.0 has solved this for me.

@kurtmilam
Copy link

kurtmilam commented May 11, 2018

Similar (perhaps identical) behavior started occurring recently for me, as well. This is new behavior (started within the past couple of weeks).

Issues

  1. nodemon is restarting my node application arbitrarily, at an estimated average rate of once per 30 seconds, even when no files in the watched directory have been changed. It reports triggering files, but those files have not been changed.
  2. nodemon seems to disregard the ignore settings in my config file, as it reports files under ignored directories as the triggers for restarts, even when those files have not been changed by any process.

To clarify, nodemon reports trigger files under ignored and watched directories, even when those files have not been changed by any process.

Environment

WSL (Ubuntu) on Windows 10 Pro 64bit

node -v: 8.11.1
nodemon -v: 1.17.3
I have also tried with versions 1.15.0 and 1.17.4 .
1.17.4 seems best-behaved. It seems to respect the ignore settings in my config file, which is an improvement, but it still restarts arbitrarily, reporting triggering files that have not changed.

nodemon.json:

{
  "verbose": true,
  "ignore": [
    ".idea/*",
    "migrations/*",
    "fixtures/*"
  ]
}

Dump

 [33m[nodemon] 1.17.4 [39m
 [33m[nodemon] reading config ./nodemon.json [39m
 [33m[nodemon] to restart at any time, enter `rs` [39m
 [33m[nodemon] or send SIGHUP to 28898 to restart [39m
 [33m[nodemon] ignoring: .idea/**/* migrations/**/* fixtures/**/* [39m
 [33m[nodemon] watching: *.* [39m
 [33m[nodemon] watching extensions: js,mjs,json [39m
--------------
node: v8.11.1
nodemon: 1.17.4
command: /root/.nvm/versions/node/v8.11.1/bin/node /mnt/e/dev/masked/node_modules/.bin/nodemon --dump
cwd: /mnt/e/dev/masked
OS: linux x64
--------------
{ run: false,
  system: 
   { cwd: '/mnt/e/dev/masked' },
  required: false,
  dirs: [ '/mnt/e/dev/masked' ],
  timeout: 1000,
  options: 
   { dump: true,
     verbose: true,
     ignore: 
      [ '**/.git/**',
        '**/.nyc_output/**',
        '**/.sass-cache/**',
        '**/bower_components/**',
        '**/coverage/**',
        '**/node_modules/**',
        '.idea/*',
        'migrations/*',
        'fixtures/*',
        re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*|\.idea\/.*|migrations\/.*|fixtures\/.*/ ],
     watch: [ '*.*', re: /.*\..*/ ],
     ignoreRoot: 
      [ '**/.git/**',
        '**/.nyc_output/**',
        '**/.sass-cache/**',
        '**/bower_components/**',
        '**/coverage/**',
        '**/node_modules/**' ],
     restartable: 'rs',
     colours: true,
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     runOnChangeOnly: false,
     signal: 'SIGUSR2',
     stdout: true,
     watchOptions: {},
     execOptions: 
      { script: 'server.js',
        exec: 'node',
        args: [],
        scriptPosition: 0,
        nodeArgs: undefined,
        execArgs: [],
        ext: 'js,mjs,json',
        env: {} },
     monitor: 
      [ '*.*',
        '!**/.git/**',
        '!**/.nyc_output/**',
        '!**/.sass-cache/**',
        '!**/bower_components/**',
        '!**/coverage/**',
        '!**/node_modules/**',
        '!.idea/**/*',
        '!migrations/**/*',
        '!fixtures/**/*' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: 
   [ '/mnt/e/dev/masked/nodemon.json' ],
  watchInterval: null,
  signal: 'SIGUSR2',
  command: 
   { raw: { executable: 'node', args: [ 'server.js' ] },
     string: 'node server.js' } }
--------------
 [33m[nodemon] exiting [39m

@remy
Copy link
Owner

remy commented May 11, 2018

@kurtmilam can you share the output of --dump and include the log of the restart? Maybe even with DEBUG=nodemon* as an env value which would give me more to debug with.

@kurtmilam
Copy link

@remy I added the dump info to my original comment ^^

Thanks for taking a look!

@keijoko
Copy link

keijoko commented May 16, 2018

Same is happening for me. Nodemon triggers restarts arbitrarily on files that have not changed and seems not to respect --ignore from command line.
WSL (Ubuntu) on Windows 10 Pro 64bit
node -v: 8.11.1
nodemon -v: 1.17.3

Same setup used to work fine and it started a week ago, around the same time Windows and WSL update was released (running Version 10.0.17134 Build 17134).

@lpgera
Copy link
Contributor

lpgera commented May 23, 2018

I am having a similar issue, with restarts triggering by unchanged files.
OS: Windows 10 64bit
node: 8.11.2
nodemon: 1.17.4

I could narrow down the problem by running a chokidar.watch(...) in parallel with nodemon, and chokidar also reports changes to the same files, but the only thing changing in their stats is the access time:

Stats {
 dev: 841653718,
 mode: 33206,
 nlink: 1,
 uid: 0,
 gid: 0,
 rdev: 0,
 blksize: undefined,
 ino: 281474976810702,
 size: 18028,
 blocks: undefined,
 atimeMs: 1527068199042.346,
 mtimeMs: 1487846793076.423,
 ctimeMs: 1487846793076.423,
 birthtimeMs: 1487846793074.4097,
 atime: 2018-05-23T09:36:39.042Z,
 mtime: 2017-02-23T10:46:33.076Z,
 ctime: 2017-02-23T10:46:33.076Z,
 birthtime: 2017-02-23T10:46:33.074Z }

@LuckStock
Copy link

Having similar issue recently: #1354
Earlier, hadn't experienced this weird issue.
Running in legacy mode (with -L) helped, but it needs a native fix.
OS: Windows 10 64bit,
nodemon: 1.17.5
node: 8.11.2

Tried to revert to 1.11., seems working yet, but who knows, can't find the regularity of the issue.

@LuckStock
Copy link

Reverting to earlier versions doesn't help.
Seems, Microsoft has issued some update and broken fsevents or some other module that is in charge of file modification attribute.

@stale
Copy link

stale bot commented Jun 14, 2018

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label Jun 14, 2018
@baileyandy
Copy link

There are instructions on how to reproduce this in my earlier comment. I am seeing too many files being watched on the latest version (1.17.5)

@stale stale bot removed the stale no activity for 2 weeks label Jun 15, 2018
@stale
Copy link

stale bot commented Jun 29, 2018

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label Jun 29, 2018
@baileyandy
Copy link

Still seems to be an issue

@stale stale bot removed the stale no activity for 2 weeks label Jun 29, 2018
@hadikcz
Copy link

hadikcz commented Jul 8, 2018

Win 10 64bit
nodemon 1.11.0
node v9.3.0

still not fixed.. its anoying

@remy
Copy link
Owner

remy commented Jul 8, 2018

I'm not a regular windows user, so if you're finding this issue annoying, I'd strongly encourage you to help via a pull request that either fixes, or helps others to debug.

@webextensions
Copy link

Kindly look at the above comment from @baileyandy #1320 (comment)

@hadikcz
You seem to be using an older version of nodemon. As mentioned in that comment, you may use nodemon@1.15.0 and this issue wouldn't occur. In newer versions, this issue is problematic.

@remy
Though I don't have a PR, I see that this issue affects all OS.
Particularly this line:
1cda8fa#diff-b2048f4188632273753b02bbcc2e31deR52

The above line of code effectively says that if the path you are watching is a file, use that file's directory to start watching. (Note: The variable names there say that they are dealing with directories, but they might actually be dealing with files)

I hit this bug when I was trying to watch a file at the project's root and nodemon rather started watching the full project root itself.

@remy
Copy link
Owner

remy commented Jul 9, 2018

I have looked at that comment, and I also know that the line was added to fix another bug.

That line does indeed to tell chokidar to watch the directory, but the actual triggering isn't dealt with in that code, it fires a change and then it filters through the match code. Only if that passes does it actually restart.

But I'd love it if I actually had a PR that gave me a test and the fix (because if I reverse that change, it'll cause a regression).

remy added a commit that referenced this issue Jul 10, 2018
@remy remy added the has PR label Jul 10, 2018
remy added a commit that referenced this issue Jul 10, 2018
@mrchief
Copy link
Author

mrchief commented Jul 10, 2018

This is great!! Thanks for the quickfix!

@baileyandy
Copy link

Thanks for fixing this. 1.18.0 is behaving exactly as expected! 👍

@webextensions
Copy link

@remy Thanks for the fix :-)

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