Description
Current Behavior
We have an intermittent issue in our pipelines, specifically when running DTE mode. Intermittently, we run into "Failed to process project graph" on some tasks.
Full message, with verbose logging turned on.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
The "nx/js/dependencies-and-lockfile" plugin threw an error while creating dependencies:
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at readCachedParsedLockFile (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/plugins/js/index.js:104:17)
at Object.createDependencies (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/plugins/js/index.js:72:36)
at LoadedNxPlugin.createDependencies (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/internal-api.js:60:59)
at createDependencies (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker.js:73:49)
at consumeMessage (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/isolation/messaging.js:37:32)
at /builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker.js:21:47
at Socket.<anonymous> (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/utils/consume-messages-from-socket.js:13:17)
at Socket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
Tracing this back into the nx codebase
I was able to capture the file I believe this is reading (.nx/workspace-data/parsed-lock-file.json
) and it appears to be valid JSON. Attaching here.
parsed-lock-file (1).json
Expected Behavior
Project graph should process correctly
GitHub Repo
No response
Steps to Reproduce
Unfortunately I don't have consistently reproducible steps. This happens intermittently on CI when running DTE.
Nx Report
Node : 20.15.1
OS : linux-x64
pnpm : 9.5.0
nx : 19.5.2
@nx/js : 19.5.2
@nx/jest : 19.5.2
@nx/linter : 19.5.2
@nx/eslint : 19.5.2
@nx/workspace : 19.5.2
@nx/cypress : 19.5.2
@nx/devkit : 19.5.2
@nx/esbuild : 19.5.2
@nx/eslint-plugin : 19.5.2
@nx/express : 19.5.2
@nx/next : 19.5.2
@nx/node : 19.5.2
@nx/plugin : 19.5.2
@nx/react : 19.5.2
@nx/rollup : 19.5.2
@nx/storybook : 19.5.2
@nrwl/tao : 19.5.2
@nx/web : 19.5.2
@nx/webpack : 19.5.2
typescript : 5.4.3
---------------------------------------
Registered Plugins:
./libs/plugins/ohw-next/src/plugin/cypress.ts
---------------------------------------
Local workspace plugins:
@dx-ui/plugins-ohw-next
Failure Logs
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
The "nx/js/dependencies-and-lockfile" plugin threw an error while creating dependencies:
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at readCachedParsedLockFile (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/plugins/js/index.js:104:17)
at Object.createDependencies (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/plugins/js/index.js:72:36)
at LoadedNxPlugin.createDependencies (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/internal-api.js:60:59)
at createDependencies (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker.js:73:49)
at consumeMessage (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/isolation/messaging.js:37:32)
at /builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker.js:21:47
at Socket.<anonymous> (/builds/pac/hiw/dx-ui/node_modules/.pnpm/nx@19.5.2_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.11__@swc+types@0.1.9_typ_34zaltkvweqg6w6zkb34rm3w24/node_modules/nx/src/utils/consume-messages-from-socket.js:13:17)
at Socket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
SyntaxError: Unexpected end of JSON input
seems to happen when calling JSON.parse on an empty string: JSON.parse('')
Since this is intermittent, I'm wondering if there is a race condition where this cachedParsedLock file is getting written and rewritten and happened to be blank at certain times.
I'd be happy with logging the contents of the file, if an error is thrown, or trying to recreate the parsedLockFile on an error rather than throwing an unrecoverable error.
CI Scripts
pnpm nx-cloud start-ci-run
pnpm nx affected -t lint --quiet --parallel=3 --base=$NX_BASE --head=$NX_HEAD &
pnpm nx affected -t build --parallel=1 --base=$NX_BASE --head=$NX_HEAD &
# more tasks... same pattern, sending job to background with `&`