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

> NX File change detected. Restarting... #17070

Closed
1 of 4 tasks
pedropmedina opened this issue May 17, 2023 · 83 comments · Fixed by #17953 or #18145
Closed
1 of 4 tasks

> NX File change detected. Restarting... #17070

pedropmedina opened this issue May 17, 2023 · 83 comments · Fixed by #17953 or #18145
Assignees
Labels
outdated scope: js scope: node Issues related to Node, Express, NestJS support for Nx type: bug

Comments

@pedropmedina
Copy link

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

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder AgentEnder added the scope: node Issues related to Node, Express, NestJS support for Nx label May 17, 2023
@salihsagdilek
Copy link

salihsagdilek commented May 17, 2023

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

@thenglong
Copy link
Contributor

thenglong commented May 18, 2023

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

@YeomansIII
Copy link

YeomansIII commented May 18, 2023

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
Copy link

YeomansIII commented May 18, 2023

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:

logger.info(`NX File change detected. Restarting...`);

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.

@ibockowsky
Copy link

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 :)

@thenglong
Copy link
Contributor

thenglong commented May 25, 2023

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

@PointSingularity
Copy link

PointSingularity commented May 25, 2023

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.

@Tirke
Copy link

Tirke commented May 26, 2023

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

@jasonmacdonald
Copy link

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.

@KeithGillette
Copy link

KeithGillette commented Jun 1, 2023

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/devkit@16.2.2
     - @nrwl/devkit@16.2.2

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

@ibockowsky
Copy link

ibockowsky commented Jun 12, 2023

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

@meeroslav

@jasonmacdonald
Copy link

This is blocking us from upgrading to fix another issue we are encountering, which was resolved in #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. :(

@urugator
Copy link

urugator commented Jun 14, 2023

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.

@ggagosh
Copy link

ggagosh commented Jun 15, 2023

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

@meeroslav
Copy link
Contributor

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

@danyhiol
Copy link

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

@pedroqueiroz
Copy link

pedroqueiroz commented Jun 23, 2023

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

@bcerquiare
Copy link

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

@KranzAklilu
Copy link

KranzAklilu commented Jun 25, 2023

Even rolling back to 16.1.4 did not work for me.
yarn nx migrate nx@16.1.4
nothing changed


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

@thenglong
Copy link
Contributor

Even rolling back to 16.1.4 did not work for me. yarn nx migrate nx@16.1.4 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.

@codeninja
Copy link

codeninja commented Jun 26, 2023

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
Copy link

Even rolling back to 16.1.4 did not work for me. yarn nx migrate nx@16.1.4 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

@PointSingularity
Copy link

The issue is still present on version 16.4.1.

@jaysoo jaysoo reopened this Jul 14, 2023
@jaysoo
Copy link
Member

jaysoo commented Jul 14, 2023

What are your restart times? Is it slow but eventually starts, or never starts?

@om-mahato
Copy link

@jaysoo It does restarts, after taking a sweet amount of time shared below. Though project is small and has not much modules previously used to be instant.

image
Screenshot_20230714_181325_Clock

@jaysoo
Copy link
Member

jaysoo commented Jul 14, 2023

The slowness is from running a full webpack build, whereas previously it was in watch mode. I think I can get it to run in watch mode again and still queue the restart correctly. Let me take a look today.

@KeithGillette
Copy link

What are your restart times? Is it slow but eventually starts, or never starts?

In our project, the rebuild hangs indefinitely until a second file change is triggered, then the rebuild completes within a couple of seconds. That is, every other file change hangs.

@jaysoo
Copy link
Member

jaysoo commented Jul 14, 2023

In our project, the rebuild hangs indefinitely until a second file change is triggered, then the rebuild completes within a couple of seconds. That is, every other file change hangs.

Sounds like an issue with watch events. I made a note of it to investigate.

@andrey59412678
Copy link

@jaysoo It does restarts, after taking a sweet amount of time shared below. Though project is small and has not much modules previously used to be instant.

same situation for me

@stewones
Copy link

stewones commented Jul 15, 2023

version 16.5.2 and livereload is still insanely slow.

same here

@ggagosh
Copy link

ggagosh commented Jul 17, 2023

The slowness is from running a full webpack build, whereas previously it was in watch mode. I think I can get it to run in watch mode again and still queue the restart correctly. Let me take a look today.

Hey @jaysoo Is there an option for us to run this in watch mode again? I'd even consider patching the package if it could help restore the previous build time. Any guidance would be appreciated. 😞

@Nightbr
Copy link

Nightbr commented Jul 17, 2023

Same here, upgraded to 16.5.2 using webpack and it has a weird behavior when NX File change detected only trigger when we change code in libs and nothing happened if we change code in apps. Also very very slow live-reload.

Happy to give more information to help debug this if necessary 👌

@PointSingularity
Copy link

@jaysoo Just tried the new 16.5.3 version with my webpack Node app, and the changes happen almost instantly now.
Thank you 😄

@jasonmacdonald
Copy link

Not sure why, but my file changes take like 5 seconds to be detected now, and setting debounce seems to have no affect.

@stewones
Copy link

@jaysoo all good here now, thanks my man!

@ggagosh
Copy link

ggagosh commented Jul 18, 2023

@jaysoo works like a charm. ty man 🙌

@kurt-west
Copy link

@jaysoo thank you for your efforts, really appreciate you bringing the webpack output back.

@jaysoo
Copy link
Member

jaysoo commented Jul 18, 2023

We'll cut a beta for people to test out soon. I did some testing on my example apps and a large TS monorepo. The watch mode will help most people, and for complete correctness (but slower) people can opt into --runBuildTargetDependencies, which will rebuild all dependencies (with caching) when changes come in.

@PointSingularity
Copy link

@jaysoo But #18145 is already released with 16.5.3, or were you thinking of something else?

@jaysoo
Copy link
Member

jaysoo commented Jul 18, 2023

@jaysoo But #18145 is already released with 16.5.3, or were you thinking of something else?

Yes, you're right, I was thinking of something else in our beta releases. This fix was released in 16.5.3.

Cheers!

@andrey59412678
Copy link

Not sure why, but my file changes take like 5 seconds to be detected now, and setting debounce seems to have no affect.

Same thing for me. ~5 seconds to detect any changes.

@jaysoo
Copy link
Member

jaysoo commented Jul 19, 2023

@jasonmacdonald @andrey59412678 Can you open a new issue and link to this one? It's different from the scope of this original issue. Since we are just running the build in watch mode now, the changes should be handled by the bundler (e.g. webpack, vite, etc.).

If you have a reprod to link that would help as well.

@jasonmacdonald
Copy link

jasonmacdonald commented Jul 21, 2023

@jaysoo I figured my issue out by turning on profile: true in webpack so I could see what was happening. Unfotunately, the lack of any console output during rebuild will lead a lot of people to think something is wrong with NX, when it may actually be a slow build in webpack.

To fix this, I ended up setting progress: true in my serve project which provides a nice little one liner in the console that updates showing the build progress. That helps us to know that something is happening and it's not just hanging. Hope that helps.

"buildTargetOptions": {
         "progress": true
}

@jaysoo
Copy link
Member

jaysoo commented Jul 27, 2023

@jaysoo I figured my issue out by turning on profile: true in webpack so I could see what was happening. Unfotunately, the lack of any console output during rebuild will lead a lot of people to think something is wrong with NX, when it may actually be a slow build in webpack.

To fix this, I ended up setting progress: true in my serve project which provides a nice little one liner in the console that updates showing the build progress. That helps us to know that something is happening and it's not just hanging. Hope that helps.

"buildTargetOptions": {
         "progress": true
}

Got it. We'll double-check to make sure progress is on by default, and maybe show a general indicator if possible.

@adamwdennis
Copy link

FWIW, the following fixed the issue for me when upgrading @nx/js (et. al.) from v16.4.0-beta.5 to v16.7.0:

project.json for my nestjs app that uses graphql (the issue was that it emits the schema file after watch is started)

"serve": {
  "options": {
    "runBuildTargetDependencies": true
  },
}

@vbuongiovanni
Copy link

This is probably obvious.. but for anyone who is incapable of following simple directions (such as myself), I hope this will help:

I was experiencing similar issues with egregious restart times after my team updated NX. After all the proposed fixes mentioned above failed to resolve my issue, I realized that I never ran the following two nx commands -

nx migrate latest
nx migrate --run-migrations

After that, the issues were resolved without any other modifications.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: js scope: node Issues related to Node, Express, NestJS support for Nx type: bug
Projects
None yet