nx icon indicating copy to clipboard operation
nx copied to clipboard

> NX File change detected. Restarting...

Open pedropmedina opened this issue 1 year ago • 15 comments

Current Behavior

@nx:js:node dev server is stuck on > NX File change detected. Restarting... since upgrading to 16.2.1

Expected Behavior

Dev server to work as should. I did not have this issue with 16.1.4.

GitHub Repo

No response

Steps to Reproduce

Just run npx nx run :serve with @nx/js:node as the executor.

Nx Report

Node   : 18.16.0
   OS     : darwin arm64
   npm    : 9.5.1
   Hasher : Native

   nx                 : 16.2.1
   @nx/js             : 16.2.1
   @nx/jest           : 16.2.1
   @nx/linter         : 16.2.1
   @nx/workspace      : 16.2.1
   @nx/cypress        : 16.2.1
   @nx/devkit         : 16.2.1
   @nx/esbuild        : 16.2.1
   @nx/eslint-plugin  : 16.2.1
   @nx/express        : 16.2.1
   @nx/next           : 16.2.1
   @nx/node           : 16.2.1
   @nx/react          : 16.2.1
   @nrwl/tao          : 16.2.1
   @nx/web            : 16.2.1
   nx-cloud           : 16.0.5
   typescript         : 5.0.4
   ---------------------------------------
   Community plugins:
   @nx-tools/nx-container : 4.0.3
   @nx-tools/nx-prisma    : 4.0.3

Failure Logs

No response

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

No response

pedropmedina avatar May 17 '23 20:05 pedropmedina

simular issue for windows when change something, its stuck on NX File change detected. Restarting... more or less 30 sec. then restart.

  Node   : 16.20.0
   OS     : win32 x64
   npm    : 8.19.4
   Hasher : Native

   nx (global)             : 16.2.1
   nx                      : 16.2.1
   @nx/js                  : 16.2.1
   @nx/jest                : 16.2.1
   @nx/linter              : 16.2.1
   @nx/workspace           : 16.2.1
   @nx/devkit              : 16.0.0-beta.4
   @nrwl/eslint-plugin-nx  : 16.0.0-beta.4
   @nx/nest                : 16.2.1
   @nx/node                : 16.2.1
   @nrwl/tao               : 16.2.1
   @nx/vite                : 16.2.1
   @nx/webpack             : 16.2.1
   nx-cloud                : 16.0.5
   typescript              : 5.0.4
   ---------------------------------------
   Community plugins:
   @nx/eslint-plugin-nx : 16.0.0-beta.4

salihsagdilek avatar May 17 '23 22:05 salihsagdilek

Same issue here.

   Node   : 18.16.0
   OS     : win32 x64
   npm    : 9.5.1
   Hasher : Native

   nx (global)        : 16.1.4
   nx                 : 16.2.1
   @nx/js             : 16.2.1
   @nx/jest           : 16.2.1
   @nx/linter         : 16.2.1
   @nx/workspace      : 16.2.1
   @nx/devkit         : 16.2.1
   @nx/eslint-plugin  : 16.2.1
   @nx/nest           : 16.2.1
   @nx/node           : 16.2.1
   @nx/plugin         : 16.2.1
   @nrwl/tao          : 16.2.1
   @nx/webpack        : 16.2.1
   typescript         : 5.0.4

thenglong avatar May 18 '23 08:05 thenglong

Seeing the same thing here, specifically when serving a NestJS app. Interestingly this also causes my Angular 16 app to rebuild, but when I am not serving the NestJS app, the Angular app does not rebuild. Does anyone know how to get the @nx/node:node serve to output which files it saw change?

    "serve": {
      "executor": "@nx/node:node",
      "options": {
        "buildTarget": "core:build"
      }
    },
   Node   : 18.12.1
   OS     : darwin arm64
   npm    : 8.19.2
   Hasher : Native
   
   nx                 : 16.2.1
   @nx/js             : 16.2.1
   @nx/jest           : 16.2.1
   @nx/linter         : 16.2.1
   @nx/workspace      : 16.2.1
   @nx/angular        : 16.2.1
   @nx/cypress        : 16.2.1
   @nx/devkit         : 16.2.1
   @nx/eslint-plugin  : 16.2.1
   @nx/nest           : 16.2.1
   @nx/node           : 16.2.1
   @nx/plugin         : 16.2.1
   @nrwl/tao          : 16.2.1
   @nx/webpack        : 16.2.1
   typescript         : 5.0.4
   ---------------------------------------
   Community plugins:
   @nx-plus/docusaurus       : 15.0.0-rc.0
   apollo-angular            : 5.0.0
   nest-commander-schematics : 3.0.0
   ---------------------------------------
   Local workspace plugins:
         @nisra/workspace-plugin

YeomansIII avatar May 18 '23 17:05 YeomansIII

I was able to log the detected change and as I suspected it is my GraphQL schema.gql file that is autogenerated. This didn't cause issues on nx 15.

{
  changedProjects: [ 'core' ],
  changedFiles: [ { path: 'apps/core/src/schema.gql', type: 'update' } ]
}

Adding this file to a .nxignore file at the root of the repo fixes the serve build loop. Although, I'm not sure if this is necessarily a good thing or not. https://nx.dev/reference/nxignore

In order to find the files that were being updated, I added a console.log(data); just before this line: https://github.com/nrwl/nx/blob/8ce9606a5b3376f1ca7a9e479c3bf6e277d4832a/packages/js/src/executors/node/node.impl.ts#L197

The file I added it to (just for the purpose of finding the offended file), was the compiled node.impl.js in my node-modules/ folder. So the exact location of your file and line number may vary.

YeomansIII avatar May 18 '23 18:05 YeomansIII

Issue still exists on 16.2.2, building changes performance became very poor, most errors aren't logged without --verbose, but sometimes this flag isn't changing anything :/

Downgrading to 16.1.4 - much faster build :)

ibockowsky avatar May 25 '23 08:05 ibockowsky

Serving NestJS app in development is also very slow even though it has only a few typescript files in the project.

thenglong avatar May 25 '23 14:05 thenglong

Issue still exists on 16.2.2, building changes performance became very poor, most errors aren't logged without --verbose, but sometimes this flag isn't changing anything :/

Downgrading to 16.1.4 - much faster build :)

I'm experiencing the same with logs. I am using winston to log some stuff, and the logs completely disappeared from the console, but they are still written to a file like before. So I am not sure what is causing that.

And it's taking full 10+ sec to change a single line.

PointSingularity avatar May 25 '23 15:05 PointSingularity

Experienced same problems, fixed by adding responsible files in .nxignore but we reverted anyways cause the performance are catastrophic.

Tirke avatar May 26 '23 15:05 Tirke

Can also confirm this issue. We had to downgrade to 16.1.4. Also confirmed that the very recent 16.3.0 did not fix the issue either.

jasonmacdonald avatar May 31 '23 17:05 jasonmacdonald

We are experiencing the same issue with versions greater than 16.1.4 and find that it is not fixed in today's release of 16.3.1. A second file change made during the > NX File change detected. Restarting... seems to wake it up.

   Node   : 16.20.0
   OS     : darwin arm64
   npm    : 8.19.4
   Hasher : Native
   
   nx             : 16.3.1
   @nx/js         : 16.3.1
   @nx/jest       : 16.3.1
   @nx/linter     : 16.3.1
   @nx/workspace  : 16.3.1
   @nx/angular    : 16.3.1
   @nx/cypress    : 16.3.1
   @nx/devkit     : 16.2.2
   @nx/node       : 16.3.1
   @nrwl/tao      : 16.3.1
   @nx/webpack    : 16.3.1
   nx-cloud       : 16.0.5
   typescript     : 5.1.3
   ---------------------------------------
   Community plugins:
   apollo-angular : 5.0.0
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nx/[email protected]
     - @nrwl/[email protected]

UPDATE: Not fixed in 16.3.2, ... or 16.4.0, either.

KeithGillette avatar Jun 01 '23 22:06 KeithGillette

Issue still exists... Will anyone look into it?

@meeroslav

ibockowsky avatar Jun 12 '23 07:06 ibockowsky

This is blocking us from upgrading to fix another issue we are encountering, which was resolved in https://github.com/nrwl/nx/issues/16825 . Kind of stuck between a rock and a hard place now. I'm starting to regret bringing NX into our stack, as none of these issues have to do with the actual packages we use to build our app. :(

jasonmacdonald avatar Jun 12 '23 18:06 jasonmacdonald

16.3.2

  1. It watches files it did not before (causing infinite restart loops if file is generated by the restarted task)
  2. It swallows logs from webpack.
  3. It's slow.
  4. The watcher crashes if it fails to kill the process (eg because it already exited):
node:internal/errors:863
  const err = new Error(message);
              ^

Error: Command failed: taskkill /pid 3180 /T /F
ERROR: The process "3180" not found.

    at ChildProcess.exithandler (node:child_process:419:12)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
  code: 128,
  killed: false,
  signal: null,
  cmd: 'taskkill /pid 3180 /T /F'
}

Node.js v19.2.0

 >  NX   Running target serve for project api failed

   Failed tasks:

   - api:serve:development

   Hint: run the command with --verbose for more details.

error Command failed with exit code 1.

urugator avatar Jun 14 '23 10:06 urugator

16.3.2

  1. Same issue for watches
  2. It's significantly slower than the previous version 15.x 😞

Actually, slowness is more problematic, as the first one can be solved by .nxignore

ggagosh avatar Jun 15 '23 07:06 ggagosh

@ndcunningham @jaysoo can one of you have a look?

meeroslav avatar Jun 15 '23 14:06 meeroslav

Same here... this is killing development...

danyhiol avatar Jun 19 '23 21:06 danyhiol

Facing the same issues, needed to rollback to 16.1.4. :(

pedroqueiroz avatar Jun 23 '23 12:06 pedroqueiroz

+1 here. ~15sec when changes a single line.

bcerquiare avatar Jun 23 '23 17:06 bcerquiare

Even rolling back to 16.1.4 did not work for me. yarn nx migrate [email protected] nothing changed


edit: I had to remove my node_modules and reinstall everything. It's now working

KranzAklilu avatar Jun 25 '23 05:06 KranzAklilu

Even rolling back to 16.1.4 did not work for me. yarn nx migrate [email protected] nothing changed

edit: I had to remove my node_modules and reinstall everything. It's now working

I think you have to downgrade manually by edit your package.json since nx does not support migrate to lower version.

thenglong avatar Jun 25 '23 16:06 thenglong

Issue still exists on 16.4 as well.

Logging the data on this line. image

{
  changedProjects: [ 'data-mongodb' ],
  changedFiles: [
    { path: 'libs/data/mongodb/src/index.ts', type: 'update' },
    { path: 'libs/data/mongodb/src/schema.prisma', type: 'update' },
    {
      path: 'libs/data/mongodb/src/typegraphql-functional-schema.prisma',
      type: 'update'
    }
  ]
}

codeninja avatar Jun 26 '23 19:06 codeninja

Even rolling back to 16.1.4 did not work for me. yarn nx migrate [email protected] nothing changed edit: I had to remove my node_modules and reinstall everything. It's now working

I think you have to downgrade manually by edit your package.json since nx does not support migrate to lower version.

And then make sure you revert the changes to use @ns/js:node rather than @ns/node:node

codeninja avatar Jun 26 '23 19:06 codeninja

The issue is still present on version 16.4.1.

PointSingularity avatar Jun 30 '23 11:06 PointSingularity

Hey folks, sorry for waiting this long. We will do our best to try to get to the bottom of this.

Can someone make a minimal repo where this issue can be tested? That would help us to quickly identify the issue.

cc @pedropmedina @PointSingularity @codeninja

meeroslav avatar Jun 30 '23 11:06 meeroslav

@meeroslav

First, I created a standalone node app: image

One of the issues is that the restart sometimes doesn't even happen when you change files, and if changes happen often it just crashes.

https://github.com/nrwl/nx/assets/56246797/a48f724d-0db1-4632-a3ec-999be6460332

Then I created a new integrated monorepo with a node app, and then I created a new node app with webpack: image npx nx generate @nx/node:application --name=file-checker-webpack --bundler=webpack --framework=express --e2eTestRunner=none --no-interactive

Here is how long it takes for it to restart with these two projects:

https://github.com/nrwl/nx/assets/56246797/18d8e767-4438-4d5b-98a7-7169e6a2b520

In some real projects, the more files it has, the longer it takes too.

Info:

   NX       : 16.4.1     
   Node   : 18.15.0
   OS       : win32-x64
   npm    : 9.6.3

PointSingularity avatar Jun 30 '23 12:06 PointSingularity

I have also noticed an increase in "An application is already running on this port" errors when hot reloading.

On Fri, Jun 30, 2023, 7:30 AM PointSingularity @.***> wrote:

First, I created a standalone node app: [image: image] https://user-images.githubusercontent.com/56246797/250085035-29e1866e-afb9-4d80-9970-9e3f9eebd065.png

One of the issues is that the restart sometimes doesn't even happen when you change files, and if changes happen often it just crashes.

https://github.com/nrwl/nx/assets/56246797/a48f724d-0db1-4632-a3ec-999be6460332

Then I created a new integrated monorepo with a node app, and then I created a new node app with webpack: [image: image] https://user-images.githubusercontent.com/56246797/250087718-8c9ac372-8898-49f0-b748-7e954da8daee.png npx nx generate @nx/node:application --name=file-checker-webpack --bundler=webpack --framework=express --e2eTestRunner=none --no-interactive

Here is how long it takes for it to restart with these two projects:

https://github.com/nrwl/nx/assets/56246797/18d8e767-4438-4d5b-98a7-7169e6a2b520

In some real projects, the more files it has, the longer it takes too.

Info:

NX : 16.4.1 Node : 18.15.0 OS : win32-x64 npm : 9.6.3

— Reply to this email directly, view it on GitHub https://github.com/nrwl/nx/issues/17070#issuecomment-1614584852, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAADUQTEUHNBKA63OKKVRZLXN3BFRANCNFSM6AAAAAAYFS2AHA . You are receiving this because you were mentioned.Message ID: @.***>

codeninja avatar Jun 30 '23 12:06 codeninja

same here, it's really unstable.

stewones avatar Jun 30 '23 13:06 stewones

Can someone make a minimal repo where this issue can be tested? That would help us to quickly identify the issue.

Hey, https://github.com/ggagosh/nx-minimal you can use this as minimal repo for testing.

  1. pull
  2. npm install
  3. npm run serve

and then it's restarting and restarting. Info:

node: v18.16.0
os: macOS 13.4.1

I fix the restarting issue with the .nxignore. But the main problem for me is the speed. I don't know how can I provide the example, maybe create a new branch with an old version of nx?

Edit: https://github.com/ggagosh/nx-minimal/tree/fixed -> with 16.1.4 version, works fine

ggagosh avatar Jun 30 '23 13:06 ggagosh

Can someone make a minimal repo where this issue can be tested? That would help us to quickly identify the issue.

Hey, https://github.com/ggagosh/nx-minimal you can use this as minimal repo for testing.

  1. pull
  2. npm install
  3. npm run serve

and then it's restarting and restarting. Info:

node: v18.16.0
os: macOS 13.4.1

I fix the restarting issue with the .nxignore. But the main problem for me is the speed. I don't know how can I provide the example, maybe create a new branch with an old version of nx?

Edit: https://github.com/ggagosh/nx-minimal/tree/fixed -> with 16.1.4 version, works fine

downgraded to 16.1.4 on a project and now getting JavaScript heap out of memory 😵‍💫 better stay with the slow version

stewones avatar Jun 30 '23 14:06 stewones

We're investigating. Two things you could try in the meantime:

  1. Pass --debounce=500 to adjust how long the executor waits before running the build the restarting the process. It defaults to 1000ms (1s); you can try increasing or decreasing it.
  2. Try setting NX_NATIVE_WATCHER=true to use our native (Rust) watcher rather than @parcel/watcher. We are still testing this feature, but it is much faster and less memory intensive than the Node implementation.

The previous @nx/js:node had issues where it does not watch dependencies (only the main app), and there were issues with process handling so the new version is supposed to solve those bugs. I apologize if it's causing issues for your projects, we're investigating it so stay tuned.

jaysoo avatar Jun 30 '23 14:06 jaysoo