remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.32k stars 1.73k forks source link

Nodemon restarting without changes multiple times #1452

Closed JeetChaudhari closed 5 years ago

JeetChaudhari commented 5 years ago

Expected behaviour

[nodemon] 1.18.6 [nodemon] to restart at any time, enter rs [nodemon] watching: /mnt/d/Dev/global-tennis-cricket/api/src/*/ [Nest] 1405 - 11/20/2018, 9:42:20 AM [NestFactory] Starting Nest application...

Actual behaviour

[nodemon] 1.18.6 [nodemon] to restart at any time, enter rs [nodemon] watching: /mnt/d/Dev/global-tennis-cricket/api/src/*/ [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [Nest] 1265 - [nodemon] restarting due to changes... [nodemon] starting ts-node -r tsconfig-paths/register src/main.ts [Nest] 1405 - 11/20/2018, 9:42:20 AM [NestFactory] Starting Nest application...

It seems nodemon restarts multiple time without any changes at all. When I do changes at that time also it does restart multiple times instead of only once. I tried uninstall and install but did not help fixing the issue. It is so painfull as for every change it takes more than 30 seconds to sometimes upto 2-3 minutes to get my application in working state again. Please help me fix this.

masinamichele commented 5 years ago

I had your exact same issue, and solved by downgrading to Node.js 8. You can do it by running: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt remove nodejs sudo apt install -y nodejs

neodon commented 5 years ago

@JeetChaudhari I suspect when your app runs it might be writing to a file somewhere in your project, thus triggering restarts in a loop. Can you edit your app's start command so that it starts nodemon with the -V flag? This will cause it to display which file changes are causing restarts.

As for the performance issues, I ran into this as well with WSL. It seemed that a big part of the performance issue was Windows Defender being overzealous about scanning the WSL filesystem.

If you feel comfortable doing so, you can add an exception to Windows Defender for the Windows side of your WSL filesystem. For me it's at C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc but there might be a slight variation in the last part of that path.

JeetChaudhari commented 5 years ago

@masinamichele Thank you for letting me know, however downgrading Node.js is not an option for me.

JeetChaudhari commented 5 years ago

@neodon I will check with -V command. Also, I know performance issues with Windows Defender so I already added the project folder to exclusion list and disabled real-time protection as well as default folder of WSL which you mentioned.

JeetChaudhari commented 5 years ago

@neodon

aceonics@JEET-CHAUDHARI:/mnt/d/Dev/global-tennis-cricket/api$ nodemon -V
[nodemon] 1.18.7
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 74 to restart
[nodemon] ignoring: src/**/*.spec.ts
[nodemon] watching: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 87
[nodemon] watching 55 files
[nodemon] files triggering change check: src/main.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/main.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 98
[nodemon] files triggering change check: src/app.module.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/app.module.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 172
[nodemon] files triggering change check: src/common/common.module.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/common.module.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 246
[nodemon] files triggering change check: src/common/auth/auth.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/auth/auth.gateway.ts

[nodemon] files triggering change check: src/common/auth/auth.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/auth/auth.service.ts

[nodemon] files triggering change check: src/common/user/user.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/user/user.service.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 272
[nodemon] files triggering change check: src/common/base.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/base.service.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 338
[nodemon] files triggering change check: src/common/util.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/util.ts

[nodemon] files triggering change check: src/common/user/user.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/user/user.entity.ts

[nodemon] files triggering change check: src/common/base.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/base.entity.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 418
[nodemon] files triggering change check: src/common/auth/jwt.strategy.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/auth/jwt.strategy.ts

[nodemon] files triggering change check: src/common/user/user.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/user/user.gateway.ts

[nodemon] files triggering change check: src/common/base.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/common/base.gateway.ts

[nodemon] files triggering change check: src/cricket/cricket.module.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/cricket.module.ts

[nodemon] files triggering change check: src/cricket/ball/ball.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/ball/ball.entity.ts

[nodemon] files triggering change check: src/cricket/ball/ball.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/ball/ball.service.ts

[nodemon] files triggering change check: src/cricket/ball/ball.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/ball/ball.gateway.ts

[nodemon] files triggering change check: src/cricket/commentator/commentator.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/commentator/commentator.entity.ts

[nodemon] files triggering change check: src/cricket/commentator/commentator.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/commentator/commentator.service.ts

[nodemon] files triggering change check: src/cricket/commentator/commentator.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/commentator/commentator.gateway.ts

[nodemon] files triggering change check: src/cricket/inning/inning.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/inning/inning.entity.ts

[nodemon] files triggering change check: src/cricket/inning/inning.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/inning/inning.service.ts

[nodemon] files triggering change check: src/cricket/over/over.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/over/over.service.ts

[nodemon] files triggering change check: src/cricket/over/over.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/over/over.entity.ts

[nodemon] files triggering change check: src/cricket/inning/inning.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/inning/inning.gateway.ts

[nodemon] files triggering change check: src/cricket/match/match.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/match/match.entity.ts

[nodemon] files triggering change check: src/cricket/match/match.service.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/match/match.service.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 512
[nodemon] files triggering change check: src/cricket/scoreboard/scoreboard.gateway.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/scoreboard/scoreboard.gateway.ts

[nodemon] files triggering change check: src/cricket/scoreboard/scoreboard.servics.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/scoreboard/scoreboard.servics.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 545
[nodemon] files triggering change check: src/cricket/scoreboard/interfaces.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/scoreboard/interfaces.ts

[nodemon] files triggering change check: src/cricket/tournament/tournament.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/tournament/tournament.entity.ts

[nodemon] files triggering change check: src/cricket/pool/pool.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/pool/pool.entity.ts

[nodemon] files triggering change check: src/cricket/team/team.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/team/team.entity.ts

[nodemon] files triggering change check: src/cricket/player/player.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/player/player.entity.ts

[nodemon] files triggering change check: src/cricket/umpire/umpire.entity.ts
[nodemon] matched rule: /mnt/d/Dev/global-tennis-cricket/api/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/cricket/umpire/umpire.entity.ts

[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 568

Thing is I don't know who is changing these files.

remy commented 5 years ago

@JeetChaudhari just as a test, can you try two things:

  1. Create a completely reduced project that uses typescript (in a similar-ish) way, and using the same node and nodemon setup - see if the project restarts in the same way.
  2. Using the example from (1) does it replicate with node 8?

I appreciate that you can't downgrade your project from 10 to 8, I just want to try to narrow down the possibilities.

JeetChaudhari commented 5 years ago

@remy On it now!

JeetChaudhari commented 5 years ago

@remy Sorry for the delay, I created new nestjs project with cli, it comes with single route. I could not reproduce this issue on this new reduced project.

aceonics@JEET-CHAUDHARI:/mnt/d/Dev/aceonics/tesst$ nodemon -V
[nodemon] 1.18.7
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 530 to restart
[nodemon] ignoring: src/**/*.spec.ts
[nodemon] watching: /mnt/d/Dev/aceonics/tesst/src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[nodemon] spawning
[nodemon] child pid: 622
[nodemon] watching 5 files
[Nest] 623   - 11/28/2018, 4:01:36 PM   [NestFactory] Starting Nest application...
[Nest] 623   - 11/28/2018, 4:01:39 PM   [InstanceLoader] AppModule dependencies initialized +45ms
[Nest] 623   - 11/28/2018, 4:01:40 PM   [RoutesResolver] AppController {/}: +156ms
[Nest] 623   - 11/28/2018, 4:01:40 PM   [RouterExplorer] Mapped {/, GET} route +6ms
[Nest] 623   - 11/28/2018, 4:01:40 PM   [NestApplication] Nest application successfully started +6ms
stale[bot] commented 5 years ago

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

sergey-chuvayev commented 5 years ago

I used nest.js with graphql. The problem is that nest.js generates graphql.schema.ts while running server and nodemon listens to changes of that file and restarts the server.. again and again.

I fixed this issue by adding graphql.schema.ts to ignore in nodemon.json