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 console extension always fails to build graph when changing the file tree #2091

Open
ThePlenkov opened this issue Apr 15, 2024 · 21 comments
Labels
blocked: more info needed more info needed type: bug Something isn't working

Comments

@ThePlenkov
Copy link

ThePlenkov commented Apr 15, 2024

Hi! I have noticed that nx console extension permanently fails if file tree is changed.

Just for example - it's enough just to delete some JS file like jest.preset.js and it's already enough for the extension to stop working.

What is interesting - nx command line stays working normally.

WHat helps - is VS Code reloading, which is not really convenient.

Could you please check why it happens - it seems like the extension have some internal caching and it doesn't really catch file changes.

Node   : 20.12.0
OS     : linux-x64
npm    : 10.5.0

nx                 : 18.2.4
@nx/js             : 18.2.4
@nx/jest           : 18.2.4
@nx/linter         : 18.2.4
@nx/eslint         : 18.2.4
@nx/workspace      : 18.2.4
@nx/devkit         : 18.2.4
@nx/eslint-plugin  : 18.2.4
@nrwl/tao          : 18.2.4
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Thanks!

@ThePlenkov ThePlenkov added the type: bug Something isn't working label Apr 15, 2024
@MaxKless MaxKless added the blocked: more info needed more info needed label Apr 15, 2024
@MaxKless
Copy link
Collaborator

It would be great if you could provide some logs or any of the information we ask for when filing a bug.

  • could you provide a minimal repro of an instance where this issue happens?
  • what's your nx report results and vscode & nx console version?
  • please provide the logs from Output => Nx Language Server so I can see what's going on

@ThePlenkov
Copy link
Author

@MaxKless just did, thanks

@MaxKless
Copy link
Collaborator

MaxKless commented Apr 15, 2024

It would be great if you could provide some logs.

  • could you provide a minimal repro of an instance where this issue happens?
  • what's your vscode & nx console version?
  • please provide the logs from Output => Nx Language Server so I can see what's going on

What do you mean by 'permanently fails'? What issues are you seeing? Is the project view not showing projects anymore? Is the graph/PDV view empty? Anything else?

@ThePlenkov
Copy link
Author

ThePlenkov commented Apr 15, 2024

Well I mean when this happens i have something like this:
image

or like this:
image

But point is - even after fixing - this error stays. So i spent an hour to understand why ( because nx command works ) and then I just found out that just reloading the window helps to fix it.

@ThePlenkov
Copy link
Author

now I tried to reproduce the error with jest config and it doesn't happen, i will try to detect this situation again and will update with a log

@MaxKless
Copy link
Collaborator

Okay thanks, I've seen this issue before it's good to have another report.
Could you provide some logs? You can find them under Output -> Nx Language Server

@ThePlenkov
Copy link
Author

Sure,
usually it's something like this:

The "nx/js/dependencies-and-lockfile" plugin threw an error while creating dependencies:
    Error: "Unable to load /workspaces/fs-observability-aws/stacks/mq/jest.config.ts: No such file or directory (os error 2)"
        at buildExplicitTypeScriptDependencies (/workspaces/fs-observability-aws/node_modules/nx/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js:61:21)
        at buildExplicitDependencies (/workspaces/fs-observability-aws/node_modules/nx/src/plugins/js/project-graph/build-dependencies/build-dependencies.js:19:120)
        at Object.createDependencies (/workspaces/fs-observability-aws/node_modules/nx/src/plugins/js/index.js:70:92)
        at /workspaces/fs-observability-aws/node_modules/nx/src/project-graph/build-project-graph.js:202:47
        at Array.map (<anonymous>)
        at updateProjectGraphWithPlugins (/workspaces/fs-observability-aws/node_modules/nx/src/project-graph/build-project-graph.js:199:47)
        at async buildProjectGraphUsingContext (/workspaces/fs-observability-aws/node_modules/nx/src/project-graph/build-project-graph.js:104:24)
        at async buildProjectGraphUsingProjectFileMap (/workspaces/fs-observability-aws/node_modules/nx/src/project-graph/build-project-graph.js:68:24)
        at async buildProjectGraphAndSourceMapsWithoutDaemon (/workspaces/fs-observability-aws/node_modules/nx/src/project-graph/project-graph.js:100:30)
        at async Object.createProjectGraphAndSourceMapsAsync (/workspaces/fs-observability-aws/node_modules/nx/src/project-graph/project-graph.js:240:25)

@MaxKless
Copy link
Collaborator

Do you have more than just that snippet? I'm specifically looking for things that mention file watching. The full logs help me get a better image of where things go wrong

@ThePlenkov
Copy link
Author

I think it's not even about the error. Like for example I just started a new project and added a new library, and it's still not shown in the extension ( even when I press refresh ) but is visible in cli:
image

@MaxKless
Copy link
Collaborator

yes that sounds like an issue with file watching. Would you mind pasting your full logs from Output -> Nx Language Server when this happens? There's a bunch of information regarding file watching in there.

@igortas
Copy link

igortas commented Apr 19, 2024

I've replaced vite.config.ts to vite.config.mts and now breaks all the time, even I revert back to ts

Failed to process project graph.
  The "nx/js/dependencies-and-lockfile" plugin threw an error while creating dependencies:
    Error: "Unable to load /home/igor/projects/myprojects/coffeeshop/apps/frontend/vite.config.mts.timestamp-1713555430444-84230d8eb717d.mjs: No such file or directory (os error 2)"
        at buildExplicitTypeScriptDependencies (/home/igor/projects/myprojects/coffeeshop/node_modules/.pnpm/nx@18.3.2_@swc-node+register@1.9.0_@swc+core@1.4.16_@swc+helpers@0.5.10__@swc+types@0.1.6_typ_ilc6bha6x27zkxd3csesxxyivu/node_modules/nx/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js:61:21)

@ThePlenkov
Copy link
Author

Did you try to reload window?

@igortas
Copy link

igortas commented Apr 19, 2024

I'm removing the .nx cache manually, and it works, not works with reload...
I'm getting also NX LOCK-FILES-CHANGED all the time, I will try to skip the cache...

@MaxKless
Copy link
Collaborator

I'm working on some changes to make Nx Console more resilient to changes like this :)

@sven-tred
Copy link

sven-tred commented Apr 30, 2024

@MaxKless
I have roughly the same issue. This can happen when

  • I manually delete a page folder from the explorer
  • copy paste and existing page and rename it

The copy paste error:

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Failed to process project graph.
  The "nx/js/dependencies-and-lockfile" plugin threw an error while creating dependencies:
    Error: "Unable to load /home/usr/Documents/repos/clients/apps/webapp/src/app/cards copy/page.tsx: No such file or directory (os error 2)"
        at buildExplicitTypeScriptDependencies (/home/usr/Documents/repos/clients/node_modules/nx/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js:61:21)
        at buildExplicitDependencies (/home/usr/Documents/repos/clients/node_modules/nx/src/plugins/js/project-graph/build-dependencies/build-dependencies.js:19:120)
        at Object.createDependencies (/home/usr/Documents/repos/clients/node_modules/nx/src/plugins/js/index.js:70:92)
        at LoadedNxPlugin.createDependencies (/home/usr/Documents/repos/clients/node_modules/nx/src/project-graph/plugins/internal-api.js:27:59)
        at /home/usr/Documents/repos/clients/node_modules/nx/src/project-graph/build-project-graph.js:200:47
        at Array.map (<anonymous>)
        at updateProjectGraphWithPlugins (/home/usr/Documents/repos/clients/node_modules/nx/src/project-graph/build-project-graph.js:197:47)
        at buildProjectGraphUsingContext (/home/usr/Documents/repos/clients/node_modules/nx/src/project-graph/build-project-graph.js:103:30)
        at async buildProjectGraphUsingProjectFileMap (/home/usr/Documents/repos/clients/node_modules/nx/src/project-graph/build-project-graph.js:67:24)
        at async createAndSerializeProjectGraph (/home/usr/Documents/repos/clients/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js:229:55)] {
  name: 'ProjectGraphError'
}

The Daemon is having a hard time keeping track of files. I'm on Ubuntu 22.04.4

@MaxKless
Copy link
Collaborator

MaxKless commented Apr 30, 2024

can you try adding this to your .env
NX_ISOLATE_PLUGINS=true

It should fix this error and will be default behaviour in the future.
@ThePlenkov @igortas @sven-tred

@sven-tred
Copy link

can you try adding this to your .env NX_ISOLATE_PLUGINS=true

It should fix this error and will be default behaviour in the future. @ThePlenkov @igortas @sven-tred

That didn't quite do the trick @MaxKless :(

@kurt-west
Copy link

@MaxKless
While refactoring - moving files, renaming, etc. - TS code, I get the same The "nx/js/dependencies-and-lockfile" plugin threw an error while creating dependencies: error as the others above.

The NX_ISOLATE_PLUGINS=true doesn't make a difference in my case.

yarn nx reset fixes the problem, as does manually deleting the project-graph.json file in .nx/cache

Looking at the daemon.log file it looks like the daemon crashes when trying to create the project graph and then when you run a command after it gets stuck with a bad project graph.

Node  : 20.11.0
OS    : win-x64
yarn  : 4.1.1
nx    : 18.2.4

Moved files with drag and drop in code; cut-paste results in the same error --------------------------------------
[NX Daemon Server] - 2024-05-01T05:37:42.830Z - [WATCHER]: 0 file(s) created or restored, 3 file(s) modified, 0 file(s) deleted
[NX Daemon Server] - 2024-05-01T05:37:43.237Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX Daemon Server] - 2024-05-01T05:37:43.237Z - [REQUEST]: libs/features/global-settings/src/role/api/index.ts,libs/features/global-settings/src/role/domain/index.ts,libs/features/global-settings/src/role/contracts/index.ts
[NX Daemon Server] - 2024-05-01T05:37:43.237Z - [REQUEST]: 
[NX Daemon Server] - 2024-05-01T05:37:43.293Z - Error detected when creating a project graph: Failed to create dependencies. See above for errors
[NX Daemon Server] - 2024-05-01T05:37:43.293Z - Time taken for 'hash changed files from watcher' 2.00760000012815ms

Tried to start the project with here -------------------------------------------------------------------------------
[NX Daemon Server] - 2024-05-01T05:37:47.130Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-01T05:37:47.131Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-05-01T05:37:47.131Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-01T05:37:47.132Z - [REQUEST]: Client Request for Project Graph Received
[NX Daemon Server] - 2024-05-01T05:37:47.132Z - [REQUEST]: Responding to the client with an error. Error when preparing serialized project graph. The Daemon Process threw an error while calculating the project graph. Convert this error to a ProjectGraphError to get more information.
DaemonProjectGraphError: The Daemon Process threw an error while calculating the project graph. Convert this error to a ProjectGraphError to get more information.
    at processFilesAndCreateAndSerializeProjectGraph (D:\nx-sandbox\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:182:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Timeout._onTimeout (D:\nx-sandbox\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:84:13)

@MaxKless
Copy link
Collaborator

MaxKless commented May 2, 2024

thanks for checking it out. After setting the env variable, did you run nx reset & restart VSCode?
Otherwise the bug still persists and I will look into it.

@kurt-west
Copy link

thanks for checking it out. After setting the env variable, did you run nx reset & restart VSCode? Otherwise the bug still persists and I will look into it.

The env is still set and verified to be active in the env, restarted code/computer multiple times, and nx reset at least 20 times due to it crashing.

@MaxKless
Copy link
Collaborator

MaxKless commented May 2, 2024

That makes sense because the env var is handled only in later versions... my bad, forgot to check.
If you can try updating to the latest nx 19 beta or be patient for just a few more days, the plugin isolation code should be available to you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: more info needed more info needed type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants