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

16.4: Failed to process the project graph with "nx-js-graph-plugin" #17987

Closed
3 of 4 tasks
tido64 opened this issue Jul 6, 2023 · 25 comments
Closed
3 of 4 tasks

16.4: Failed to process the project graph with "nx-js-graph-plugin" #17987

tido64 opened this issue Jul 6, 2023 · 25 comments

Comments

@tido64
Copy link

tido64 commented Jul 6, 2023

Current Behavior

After upgrading nx from 16.3 to 16.4, yarn build fails to find any projects:

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Source project does not exist: @rnx-kit/patcher-rnmacos

Expected Behavior

yarn build successfully builds all packages in the repository.

GitHub Repo

https://github.com/microsoft/rnx-kit

Steps to Reproduce

  1. Checkout the branch in chore(deps): update dependency nx to v16.4.1 microsoft/rnx-kit#2500
  2. Run yarn build

Nx Report

>  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Source project does not exist: @rnx-kit/tools-workspaces

   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

Failure Logs

>  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Source project does not exist: @rnx-kit/tools-workspaces

   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

Operating System

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

Additional Information

Full build log here: https://github.com/microsoft/rnx-kit/actions/runs/5474602740/jobs/9969582689?pr=2500

@tido64
Copy link
Author

tido64 commented Jul 6, 2023

Possibly a duplicate of #17781?

@tido64
Copy link
Author

tido64 commented Jul 7, 2023

Workaround: Remove npmScope from nx.json.

The value of sourceProjectName passed to addDependency is the full project name with scope, but the graph contains names without scope, thus failing this check here:

if (
!this.graph.nodes[sourceProjectName] &&
!this.graph.externalNodes[sourceProjectName]
) {
throw new Error(`Source project does not exist: ${sourceProjectName}`);
}

Update: I've just learned that npmScope was deprecated in 16.2 (6b928bc). It isn't scheduled to be removed until 17 though.

@AgentEnder
Copy link
Member

Hey, can you try again with latest? We've made some updates that should make this less likely to happen.

@tido64
Copy link
Author

tido64 commented Jul 19, 2023

Hey, can you try again with latest? We've made some updates that should make this less likely to happen.

Hi, I've tested against 16.5.3 and it seems be working again. That said, since it's deprecated, we've removed it already. I couldn't get the autodetection working though despite setting the root package name to our scope. What is the recommended way to do this now?

diff --git a/package.json b/package.json
index 1d1878f9..17bffc6d 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
-  "name": "rnx-kit",
+  "name": "@rnx-kit/root",
   "version": "0.1.0",
   "private": true,
   "description": "",

Run:

% yarn nx build scripts

 >  NX   Cannot find project 'scripts'

This only works with npmScope.

@JanPretzel
Copy link
Contributor

JanPretzel commented Jul 21, 2023

We seem to have the same/a similar problem when running npx nx run-many --target=lint but only on Azure Pipelines. Upgrading to 16.5.3 and removing npmScope did not help.

Edit:
Sorry I didn't read correctly, we have a slightly different problem here our error was

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Maximum call stack size exceeded

@rizentium
Copy link

When I tried to create a new project using the command npx create-nx-workspace --pm yarn, I encountered the same problem.

To solve the issue, I decided to create a new project without specifying a package manager by running the command

npx create-nx-workspace.

@dlhck
Copy link

dlhck commented Aug 4, 2023

Is there any update on that? I have the same problem with the latest v16.6.0. The error occurs when I execute graphql-codegen via the nx:run-commands executor.

@josip8
Copy link

josip8 commented Aug 9, 2023

We seem to have the same/a similar problem when running npx nx run-many --target=lint but only on Azure Pipelines. Upgrading to 16.5.3 and removing npmScope did not help.

Edit: Sorry I didn't read correctly, we have a slightly different problem here our error was

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Maximum call stack size exceeded

Same issue here but only on Azure Pipelines with pnpm nx build {{project-name}} and pnpm nx run-many -t test commands.

@JanPretzel
Copy link
Contributor

Not sure if this will help you, but we temporarily fixed this by given the Azure workers more cores (4 cores seems to work for us). But this is of course only possible if you are running self-hosted workers.

@josip8
Copy link

josip8 commented Aug 9, 2023

We are currently using 2 core / 8 GB machines, I will wait for the fix because we can live without nx for now
Thank you for the advice🙂

@dlhck
Copy link

dlhck commented Aug 10, 2023

I have this problem locally on my Macbook Pro M2 😅 So I cannot add more cores sadly, haha

@kekami
Copy link

kekami commented Aug 14, 2023

Upgrading to nx@16.7.0-rc.0 resolved this issue for me

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   Maximum call stack size exceeded

@FrozenPandaz
Copy link
Collaborator

Can you all please retry with the latest version of Nx? (16.7.0)

Also, could you run the failing command with the NX_VERBOSE_LOGGING=true environment variable please?

@dlhck
Copy link

dlhck commented Aug 16, 2023

@FrozenPandaz just tested 10min with the local setup where I had this problem all the time. Works fine now with v16.7.0. I upgrade another project and look if this error occurs again. Thank you!

@TriPSs
Copy link
Contributor

TriPSs commented Aug 17, 2023

@FrozenPandaz upgraded to the latest version with nx migrate latest (from 16.5.0), than ran NX_VERBOSE_LOGGING=true nx migrate --run-migrations


 >  NX   Failed to parse yarn lockfile

   Please open an issue at `https://github.com/nrwl/nx/issues/new?template=1-bug.yml` and provide a reproduction.

Original error: Target project does not exist: npm:react-loadable@ct-loadable@npm:5.5.2


   Error: Target project does not exist: npm:react-loadable@ct-loadable@npm:5.5.2
    at validateCommonDependencyRules (<project>/node_modules/nx/src/project-graph/project-graph-builder.js:285:15)
    at validateDependency (<project>/node_modules/nx/src/project-graph/project-graph-builder.js:275:5)
    at ProjectGraphBuilder.addDependency (<project>/node_modules/nx/src/project-graph/project-graph-builder.js:162:9)
    at ProjectGraphBuilder.addStaticDependency (<project>/node_modules/nx/src/project-graph/project-graph-builder.js:79:14)
    at <project>/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:174:41
    at Array.forEach (<anonymous>)
    at <project>/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:170:49
    at Array.forEach (<anonymous>)
    at <project>/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:168:72
    at Array.forEach (<anonymous>)


 >  NX   Failed to run explicitly-set-projects-to-update-buildable-deps from @nx/js. This workspace is NOT up to date!


 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

TypeError [ERR_INVALID_ARG_TYPE]: Failed to process the project graph with "nx-js-graph-plugin".
The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at writeFileSync (node:fs:2316:5)
    at writeLastProcessedLockfileHash (<project>/node_modules/nx/src/plugins/js/index.js:53:28)
    at <project>/node_modules/nx/src/plugins/js/index.js:26:17
    at Generator.next (<anonymous>)
    at <project>/node_modules/tslib/tslib.js:169:75
    at new Promise (<anonymous>)
    at Object.__awaiter (<project>/node_modules/tslib/tslib.js:165:16)
    at Object.processProjectGraph (<project>/node_modules/nx/src/plugins/js/index.js:16:57)
    at <project>/node_modules/nx/src/project-graph/build-project-graph.js:138:42
    at Generator.next (<anonymous>)
Command failed: yarn nx _migrate --run-migrations

 >  NX   Command failed: yarn nx migrate --run-migrations


Error: Command failed: yarn nx migrate --run-migrations
    at checkExecSyncError (node:child_process:885:11)
    at execSync (node:child_process:957:15)
    at runNxSync (/private/var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/tmp-9166-p9jZGualUM5Q/node_modules/nx/src/utils/child-process.js:26:34)
    at /private/var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/tmp-9166-p9jZGualUM5Q/node_modules/nx/src/command-line/migrate/migrate.js:972:43
    at Generator.next (<anonymous>)
    at /private/var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/tmp-9166-p9jZGualUM5Q/node_modules/tslib/tslib.js:169:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/private/var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/tmp-9166-p9jZGualUM5Q/node_modules/tslib/tslib.js:165:16)
    at runMigrations (/private/var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/tmp-9166-p9jZGualUM5Q/node_modules/nx/src/command-line/migrate/migrate.js:965:20)
Command failed: /var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/tmp-9166-p9jZGualUM5Q/node_modules/.bin/nx _migrate --run-migrations

During the migration we also got a lot of:

Could not format <an app>/project.json. Error: "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Promise"

@SF97
Copy link

SF97 commented Aug 17, 2023

I have an issue which seems to be related, at least the output is somewhat the same. I can reproduce it with Lerna. Here's the full description: lerna/lerna#3807

The issue happens when hot loading NX 16.3 or higher with pnpm dlx

@meeroslav
Copy link
Contributor

The Lerna issue is not related, despite the similar error report @SF97

@meeroslav meeroslav self-assigned this Aug 17, 2023
@meeroslav
Copy link
Contributor

I think this might be related to #18646

@jbean96
Copy link
Contributor

jbean96 commented Aug 17, 2023

We were still able to repro this on the latest version 16.7.1, we narrowed down to this yarn.lock change (git diff below). Note that this yarn.lock change was on a branch where we were on 16.6.0 but it repro'd on 16.7.1.

Hope this helps!

 "@rollup/plugin-node-resolve@npm:^15.0.1":
-  version: 15.1.0
-  resolution: "@rollup/plugin-node-resolve@npm:15.1.0"
+  version: 15.2.0
+  resolution: "@rollup/plugin-node-resolve@npm:15.2.0"
   dependencies:
     "@rollup/pluginutils": ^5.0.1
     "@types/resolve": 1.20.2
@@ -9016,7 +9016,7 @@ __metadata:
   peerDependenciesMeta:
     rollup:
       optional: true
-  checksum: 83617cdbb90cb780251e8b16dc1671e35bde90b8d4d30e008aefe706b5b643057f6299bdd3226b2a30bf5e4f807a880169de3faa47b9f2ba38d39f294f85f951
+  checksum: 92abfd7f1f5df08d71e4b8dd433d31cf1d62f68891ae3dd5e03a8a7f8d42d9c4433c14a25ead04204fea8235c663a3bbb66ba5528103a6dab66bd8c124f85a0d
   languageName: node
   linkType: hard

@@ -11366,7 +11366,7 @@ __metadata:
   languageName: node
   linkType: hard

-"@swc/helpers@npm:0.4.14, @swc/helpers@npm:^0.4.14":
+"@swc/helpers@npm:0.4.14, legacy-swc-helpers@npm:@swc/helpers@=0.4.14":
   version: 0.4.14
   resolution: "@swc/helpers@npm:0.4.14"
   dependencies:
@@ -11375,6 +11375,16 @@ __metadata:
   languageName: node
   linkType: hard

+"@swc/helpers@npm:^0.4.14":
+  version: 0.4.36
+  resolution: "@swc/helpers@npm:0.4.36"
+  dependencies:
+    legacy-swc-helpers: "npm:@swc/helpers@=0.4.14"
+    tslib: ^2.4.0
+  checksum: 20b9f021a9711633d709ef1c231423eb079cb7ed14ad191dc9583b0b46684a95d0e87c3efd7472e7673ddbd30eb200c21490ab43ad251df8f845cd09df3d236f
+  languageName: node
+  linkType: hard
+
 "@swc/helpers@npm:^0.5.0, @swc/helpers@npm:~0.5.0":
   version: 0.5.1
   resolution: "@swc/helpers@npm:0.5.1"
@@ -19710,9 +19720,9 @@ __metadata:
   linkType: hard

 "electron-to-chromium@npm:^1.4.477":
-  version: 1.4.492
-  resolution: "electron-to-chromium@npm:1.4.492"
-  checksum: 39ae22dd651a3daa210e8e8e42c9725c7019d95667413423da48253dd0a14dfd070ddb53a97eb98a60003a7790978b9093ab5c530671562f2d3e65888e1451f6
+  version: 1.4.495
+  resolution: "electron-to-chromium@npm:1.4.495"
+  checksum: b076b1f5ef61f45ca03f4dce47ec280c705405b0cfd3741cc791ef0172a73122846bdf4bddddc4120dece693166e17fe0d6efc847664ecc5852fbec4df9c3153
   languageName: node
   linkType: hard

@@ -29725,11 +29735,11 @@ __metadata:
   linkType: hard

 "node-abi@npm:^3.3.0":
-  version: 3.46.0
-  resolution: "node-abi@npm:3.46.0"
+  version: 3.47.0
+  resolution: "node-abi@npm:3.47.0"
   dependencies:
     semver: ^7.3.5
-  checksum: 8d23e6813c4d62e69e460f55d6c649710df735e39ec2febbeb0a0e395bff4f437833a9bb069618254614fa1e19fbd0530b50b63a17b912e8febf110076087225
+  checksum: ff8498dcd4a805ebf0af27162023bb17e56cb973c955d6c411ebce0938b0827e34323ede846b635daff516d5cd2ea8d64f9d99f2d63f61d1d7469415323fa9a6
   languageName: node
   linkType: hard

@jyono
Copy link

jyono commented Aug 23, 2023

i'm experiencing this on version 16.7.4

any ideas?

@Chlebamaticon
Copy link

Chlebamaticon commented Aug 24, 2023

Tried with 16.8.0-beta.2 - as I was also affected by #17407 - and unfortunately I am getting exactly the same error as here described.

Stack trace;

 >  NX   Failed to process the project graph with "nx-js-graph-plugin".

   The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
   
   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

{
  stack: 'TypeError [ERR_INVALID_ARG_TYPE]: Failed to process the project graph with "nx-js-graph-plugin".\n' +
    'The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined\n' +
    '    at writeFileSync (node:fs:2195:5)\n' +
    '    at writeLastProcessedLockfileHash (/Users/admin/Workspace/node_modules/nx/src/plugins/js/index.js:53:28)\n' +
    '    at /Users/admin/Workspace/node_modules/nx/src/plugins/js/index.js:26:17\n' +
    '    at Generator.next (<anonymous>)\n' +
    '    at /Users/admin/Workspace/node_modules/tslib/tslib.js:167:75\n' +
    '    at new Promise (<anonymous>)\n' +
    '    at Object.__awaiter (/Users/admin/Workspace/node_modules/tslib/tslib.js:163:16)\n' +
    '    at Object.processProjectGraph (/Users/admin/Workspace/node_modules/nx/src/plugins/js/index.js:16:57)\n' +
    '    at /Users/admin/Workspace/node_modules/nx/src/project-graph/build-project-graph.js:138:42\n' +
    '    at Generator.next (<anonymous>)',
  message: 'Failed to process the project graph with "nx-js-graph-plugin".\n' +
    'The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined\n' +
    '\n' +
    'Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.\n' +
    'If the error persists, please run "nx reset".',
  code: 'ERR_INVALID_ARG_TYPE'
}

@josetapadas
Copy link

I'm also getting a wierd behaviour now on 16.7.3 where my projects were simply stopped being found by nx even though nothing has changed.

nx show projects always show empty and the generated project-graph.json simply do not add any reference to it. Curiously enough the generators add the new apps or libs to the proper configured folders on nx.json but don't find them at all.

@meeroslav meeroslav removed the blocked: retry with latest Retry with latest release or head. label Aug 29, 2023
@meeroslav
Copy link
Contributor

For those of you who are experiencing this on 16.8.0-beta.X can you create a minimal repo where this can be reproduced? The originally reported issue has been fixed by the OP.

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@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 Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests