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

Generating a new library automatically edits nx.json by adding the nx-eslint plugin causing random performance issues #26953

Closed
1 of 4 tasks
FrancescoBorzi opened this issue Jul 16, 2024 · 5 comments
Assignees
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug

Comments

@FrancescoBorzi
Copy link

Current Behavior

I'm using NX version 18.3.5 at work.

  • EDIT: also tried with NX 19.4.3 and the problem is still the same. However, with NX 17.2.4 there is no such issue.

Whenever I add a new library using the command:

npx nx g @nx/js:lib 

The following code gets automatically added to the nx.json file of the project:

"plugins": [
    {
      "plugin": "@nx/eslint/plugin",
      "options": {
        "targetName": "eslint:lint",
        "extensions": ["ts", "tsx", "js", "jsx", "html", "vue"]
      }
    }
  ]

For some reasons, this causes big performance issues to some colleagues (not to myself) whenever they open the same project with their editors.

This happened already twice and it took us quite some time to debug and figure out what was causing the issue. It is still not clear why NX changes the global nx.json configuration when performing the task of creating a new library.

Note: this does not happen if using NX 17, but only when using NX 18 or NX 19

Expected Behavior

Generating a new library should not create any unexpected side-effect.

GitHub Repo

https://github.com/FrancescoBorzi/nx-test-project

Steps to Reproduce

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.15.1
OS     : darwin-arm64
npm    : 10.8.2

nx (global)        : 19.4.3
nx                 : 18.3.5
@nx/js             : 18.3.5
@nx/jest           : 18.3.5
@nx/linter         : 18.3.5
@nx/eslint         : 18.3.5
@nx/workspace      : 18.3.5
@nx/angular        : 18.3.5
@nx/cypress        : 18.3.5
@nx/devkit         : 18.3.5
@nx/eslint-plugin  : 18.3.5
@nx/express        : 18.3.5
@nx/node           : 18.3.5
@nx/storybook      : 18.3.5
@nrwl/tao          : 18.3.5
@nx/web            : 18.3.5
@nx/webpack        : 18.3.5
typescript         : 5.4.5
---------------------------------------
Community plugins:
@ng-bootstrap/ng-bootstrap : 16.0.0
@ngneat/spectator          : 16.0.0
@ngrx/component-store      : 17.0.1
@ngrx/signals              : 17.2.0
@storybook/angular         : 7.6.7
ng-mocks                   : 14.13.0
ngx-bootstrap              : 12.0.0




Also reproduced with:

 NX   Report complete - copy this into the issue template

Node   : 20.15.1
OS     : darwin-arm64
npm    : 10.8.2

nx (global)        : 19.4.3
nx                 : 19.4.3
@nx/js             : 19.4.3
@nx/jest           : 19.4.3
@nx/linter         : 19.4.3
@nx/eslint         : 19.4.3
@nx/workspace      : 19.4.3
@nx/cypress        : 19.4.3
@nx/devkit         : 19.4.3
@nx/eslint-plugin  : 19.4.3
@nx/express        : 19.4.3
@nx/node           : 19.4.3
@nx/storybook      : 19.4.3
@nrwl/tao          : 19.4.3
@nx/web            : 19.4.3
@nx/webpack        : 19.4.3
typescript         : 5.2.2

Failure Logs

No response

Package Manager Version

npm --version: 10.8.2

Operating System

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

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: linter Issues related to Eslint support in Nx label Jul 16, 2024
@FrozenPandaz
Copy link
Collaborator

Adding the @nx/eslint/plugin is the intended behavior. Could you please share any insights on the performance issues you are seeing? We have merged changes to make the process more performant. Could you maybe check with Nx 19.5.0-beta.3 and higher?

@CaiZhe
Copy link

CaiZhe commented Jul 17, 2024

In VS code, we are getting this error, when this plugin is added:


[Nxls] - 2024-07-17T07:24:24.687Z - createProjectGraphAndSourceMapsAsync

[Error - 09:24:26] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 09:24:26] The Nx Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 09:24:26] Nx Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 09:24:26] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

image

Which results into Nx Console Extension not working.

@codefabriek-bam
Copy link

@CaiZhe @FrancescoBorzi same issue over here

@FrozenPandaz FrozenPandaz assigned MaxKless and unassigned AgentEnder Jul 23, 2024
@MaxKless
Copy link
Collaborator

Hey!
As Jason has said, adding the eslint plugin is expected behaviour. On new versions of Nx, we don't generate lint targets in project.json by default anymore but instead infer them via the eslint plugin.
If you want to enable this plugin for only the newly generated lib and not the entire workspace, you can add an include statement in the plugin configuration in nx.json:

{
      "plugin": "@nx/eslint/plugin",
      "include": ["path/to/lib/**/*"],
      "options": {
        "targetName": "lint"
      }
    },

After the first time this plugin is added, it's entirely feasible that project graph calculation will take a bit longer. If you're still seeing performance issues on the latest 19.5 version, please create a new issue detailing those issues with a comparison to before. What you've mentioned so far is a bit too vague to work with from our side.

For Nx Console, that error looks like you pressed the reload button while the project graph was still being computed. We will add better handling there so that no error pops up. If you still see the error above after a restart of the editor, please create a new issue in nrwl/nx-console and I will have a look! Thank you.

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 Aug 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

6 participants