Failures for test and lint runs in CI with shared cache
See original GitHub issueCurrent Behavior
Using Jenkins as CI engine.
Using shared Nx cache directory (/home/node/cache/nx
) in CI:
sed -i 's|./cache/nx|/home/node/cache/nx|' nx.json
With this setup running test and lint in distributed setup (very similar to one provided in Nrwl example):
# lint
npx nx run-many --target=lint --projects=redacted-40-projects-here --parallel
# test
npx nx run-many --target=test --projects=redacted-40-projects-here --parallel
Getting same errors on seemingly random projects. Failed projects change when re-running same CI jobs, but never fail when running without shared cache and never fail locally (with or without you cache).
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at parseJsonWithComments (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/utils/fileutils.js:44:17)
at Object.readJsonFile (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/utils/fileutils.js:40:12)
at Object.readCache (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/core/nx-deps/nx-deps-cache.js:36:67)
at Object.createProjectGraph (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:13:232)
at Object.<anonymous> (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/command-line/run-many.js:17:46)
at Generator.next (<anonymous>)
at fulfilled (/home/jenkins/agent/workspace/redacted/node_modules/tslib/tslib.js:111:62)
> nx run redacted:lint
Linting "redacted"...
Error while loading rule '@nrwl/nx/enforce-module-boundaries': Unexpected end of JSON input
Occurred while linting /home/jenkins/agent/workspace/redacted/libs/redacted/src/index.ts
Expected Behavior
It should be possible to set shared cache in CI environment without getting jobs failed.
Steps to Reproduce
It might be difficult to recreate whole environment so the issue would be reproducible as it is not clear what causes it. Please share any ideas what could be attempted to narrow down the root cause of this and I will give them a try.
Failure Logs
See under “Current Behaviour”.
Environment
The report is from local development environment, but it is same Node.js version as on CI:
> NX Report complete - copy this into the issue template
Node : 14.15.4
OS : darwin x64
npm : 6.14.11
nx : Not Found
@nrwl/angular : 11.1.1
@nrwl/cli : 11.1.1
@nrwl/cypress : 11.1.1
@nrwl/devkit : 11.1.1
@nrwl/eslint-plugin-nx : 11.1.1
@nrwl/express : Not Found
@nrwl/jest : 11.1.1
@nrwl/linter : 11.1.1
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 11.1.1
@nrwl/web : Not Found
@nrwl/workspace : 11.1.1
typescript : 4.0.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
@vsavkin It was me that created the PR that attempts to fix it, but it will definitely not address the linting issue. Could we have the issues open till it is confirmed?
readJsonFile
could be wrapped to try/catch forreadCache
: https://github.com/nrwl/nx/blob/2c7fa421eba594acf029fa44c0e19b093b9c01cb/packages/workspace/src/core/nx-deps/nx-deps-cache.ts#L58This should solve issue with test target runs, but lint runs seems to fail in other way.