Error reading nxdeps.json
See original GitHub issueCurrent Behavior
While running some commands in parallel we receive the following error:
Error reading '/home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: ValueExpected in /home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json at position 0
at parseJson (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/json.js:30:15)
at readJsonFile (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/fileutils.js:21:37)
at readCache (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/nx-deps/nx-deps-cache.js:41:46)
at Object.readCachedProjectGraph (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:19:61)
at jestExecutor2 (/home/circleci/project/repo/node_modules/@*******org/nx-jest/src/executors/jest/jest.impl.js:107:46)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.
(Note: we are using a jest executor that wraps the Nrwl Nx Jest executor to modify the jest config, doesn’t do anything with Nx itself, can find the code here, https://github.com/trellisorg/platform/tree/master/packages/nx-jest, it shouldn’t have anything to do with it.)
We have 3 e2e test suites (that actually just use jest) for our API, each of them has a dependsOn target:
"dependsOn": [
{ "target": "build", "projects": "dependencies" }
]
So that all dependencies of these e2e test suites (which are just node projects in the apps
folder) are built (or pulled from cache) prior to running the e2e tests.
Then we run
yarn nx affected --target feature-e2e
and receive the error (not every time though)
Expected Behavior
Should not error and running commands in parallel should work fine.
Steps to Reproduce
This issue may not be prioritized if details are not provided to help us reproduce the issue.
Failure Logs
Error reading '/home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: ValueExpected in /home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json at position 0
at parseJson (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/json.js:30:15)
at readJsonFile (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/fileutils.js:21:37)
at readCache (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/nx-deps/nx-deps-cache.js:41:46)
at Object.readCachedProjectGraph (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:19:61)
at jestExecutor2 (/home/circleci/project/repo/node_modules/@*******org/nx-jest/src/executors/jest/jest.impl.js:107:46)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data
Environment
> NX Report complete - copy this into the issue template
Node : 12.22.7
OS : darwin x64
yarn : 1.22.17
nx : 13.8.3
@nrwl/angular : 13.8.3
@nrwl/cli : 13.8.3
@nrwl/cypress : 13.8.3
@nrwl/detox : undefined
@nrwl/devkit : 13.8.3
@nrwl/eslint-plugin-nx : 13.8.3
@nrwl/express : 13.8.3
@nrwl/jest : 13.8.3
@nrwl/js : 13.8.3
@nrwl/linter : 13.8.3
@nrwl/nest : 13.8.3
@nrwl/next : undefined
@nrwl/node : 13.8.3
@nrwl/nx-cloud : 13.1.5
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.8.3
@nrwl/tao : 13.8.3
@nrwl/web : 13.8.3
@nrwl/workspace : 13.8.3
typescript : 4.5.5
rxjs : 7.4.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:33
- Comments:17 (9 by maintainers)
I noticed that the
writeCache()
is getting called over and over again just writing the same data that is already there every time the graph is read. Adding a simple check to see if the data it is writing is already what is there should reduce the chances that it is in the middle of writing when reading starts.Can someone on the NX team weigh in on this (e.g. what solution would you merge if someone worked on it)?