nx icon indicating copy to clipboard operation
nx copied to clipboard

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

Open tido64 opened this issue 1 year ago • 1 comments

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 https://github.com/microsoft/rnx-kit/pull/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

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

Additional Information

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

tido64 avatar Jul 06 '23 11:07 tido64

Possibly a duplicate of #17781?

tido64 avatar Jul 06 '23 16:07 tido64

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:

https://github.com/nrwl/nx/blob/3edbe49fa2ea0503547ba5bff707a67382fb4d13/packages/nx/src/project-graph/project-graph-builder.ts#L258-L263

Update: I've just learned that npmScope was deprecated in 16.2 (https://github.com/nrwl/nx/commit/6b928bc250406aa5c31cb56b07361596d64e90dd). It isn't scheduled to be removed until 17 though.

tido64 avatar Jul 07 '23 08:07 tido64

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

AgentEnder avatar Jul 18 '23 16:07 AgentEnder

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.

tido64 avatar Jul 19 '23 14:07 tido64

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

JanPretzel avatar Jul 21 '23 10:07 JanPretzel

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.

rizentium avatar Jul 26 '23 16:07 rizentium

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.

davidhoeck avatar Aug 04 '23 16:08 davidhoeck

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.

josip8 avatar Aug 09 '23 07:08 josip8

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.

JanPretzel avatar Aug 09 '23 07:08 JanPretzel

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🙂

josip8 avatar Aug 09 '23 08:08 josip8

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

davidhoeck avatar Aug 10 '23 19:08 davidhoeck

Upgrading to [email protected] resolved this issue for me

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

   Maximum call stack size exceeded

kekami avatar Aug 14 '23 20:08 kekami

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?

FrozenPandaz avatar Aug 15 '23 21:08 FrozenPandaz

@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!

davidhoeck avatar Aug 16 '23 07:08 davidhoeck

@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"

TriPSs avatar Aug 17 '23 08:08 TriPSs

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: https://github.com/lerna/lerna/issues/3807

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

SF97 avatar Aug 17 '23 08:08 SF97

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

meeroslav avatar Aug 17 '23 18:08 meeroslav

I think this might be related to https://github.com/nrwl/nx/pull/18646

meeroslav avatar Aug 17 '23 18:08 meeroslav

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

jbean96 avatar Aug 17 '23 20:08 jbean96

i'm experiencing this on version 16.7.4

any ideas?

jyono avatar Aug 23 '23 19:08 jyono

Tried with 16.8.0-beta.2 - as I was also affected by https://github.com/nrwl/nx/pull/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'
}

Chlebamaticon avatar Aug 24 '23 12:08 Chlebamaticon

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.

josetapadas avatar Aug 24 '23 20:08 josetapadas

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.

meeroslav avatar Sep 01 '23 15:09 meeroslav

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[bot] avatar Sep 16 '23 00:09 github-actions[bot]

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[bot] avatar Oct 31 '23 00:10 github-actions[bot]