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

ValueExpected in ... at position 4161536 #12389

Closed
B1Z1 opened this issue Oct 4, 2022 · 5 comments
Closed

ValueExpected in ... at position 4161536 #12389

B1Z1 opened this issue Oct 4, 2022 · 5 comments

Comments

@B1Z1
Copy link

B1Z1 commented Oct 4, 2022

Sometimes on CI while executing unit tests we get error with nxdeps.json. This behavior is rare last time, but we still have it. If you need more information, let me know which you need

Current Behavior

Sometimes CI fails on Jest tests with this error

Expected Behavior

There's no error with nxdeps.json. My suggestion is maybe instead of failing the whole process we need to continually build without a graph or regenerate a graph.

Steps to Reproduce

We have an angular application with 300 buildable libraries. One of our buildable libraries fails on this error. Every time it blows up in the different libraries. We are using a basic nx configuration without any extras. CI installs everything from zero. Also postinstall executes after yarn install.

Failure Logs

[2022-10-04T09:04:54.287Z] Error reading '/home/ubuntu/workspace/PPM/REVIEW/FRONTEND_TESTS/ui/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.

[2022-10-04T09:04:54.287Z] Error: ValueExpected in /home/ubuntu/workspace/PPM/REVIEW/FRONTEND_TESTS/ui/node_modules/.cache/nx/nxdeps.json at position 4161536

[2022-10-04T09:04:54.287Z] at parseJson (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/utils/json.js:23:15)

[2022-10-04T09:04:54.287Z] at readJsonFile (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/utils/fileutils.js:23:37)

[2022-10-04T09:04:54.287Z] at readCache (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/project-graph/nx-deps-cache.js:41:49)

[2022-10-04T09:04:54.287Z] at readCachedProjectGraph (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/project-graph/project-graph.js:18:61)

[2022-10-04T09:04:54.287Z] at run (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/command-line/run.js:167:69)

[2022-10-04T09:04:54.287Z] at requireCli (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/bin/run-executor.js:17:23)

[2022-10-04T09:04:54.287Z] at Object. (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/bin/run-executor.js:12:1)

[2022-10-04T09:04:54.287Z] at Module._compile (node:internal/modules/cjs/loader:1105:14)

[2022-10-04T09:04:54.287Z] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

[2022-10-04T09:04:54.287Z] at Module.load (node:internal/modules/cjs/loader:981:32)

[2022-10-04T09:04:54.287Z] Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.

[2022-10-04T09:04:54.287Z]

[2022-10-04T09:04:54.287Z] If you are leveraging `readCachedProjectGraph()` directly then you will need to refactor your usage to first ensure that

[2022-10-04T09:04:54.287Z] the ProjectGraph is created by calling `await createProjectGraphAsync()` somewhere before attempting to read the data.

[2022-10-04T09:04:54.287Z]

[2022-10-04T09:04:54.287Z] If you encounter this error as part of running standard `nx` commands then please open an issue on https://github.com/nrwl/nx

[2022-10-04T09:04:54.287Z] at readCachedProjectGraph (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/project-graph/project-graph.js:27:15)

[2022-10-04T09:04:54.287Z] at run (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/command-line/run.js:167:69)

[2022-10-04T09:04:54.287Z] at requireCli (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/bin/run-executor.js:17:23)

[2022-10-04T09:04:54.287Z] at Object. (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/bin/run-executor.js:12:1)

[2022-10-04T09:04:54.287Z] at Module._compile (node:internal/modules/cjs/loader:1105:14)

[2022-10-04T09:04:54.287Z] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

[2022-10-04T09:04:54.287Z] at Module.load (node:internal/modules/cjs/loader:981:32)

[2022-10-04T09:04:54.287Z] at Function.Module._load (node:internal/modules/cjs/loader:822:12)

[2022-10-04T09:04:54.287Z] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)

[2022-10-04T09:04:54.287Z] at node:internal/main/run_main_module:17:47

Environment

Node : 16.16.0
OS : darwin arm64
yarn : 1.22.4

nx : 14.7.13
@nrwl/angular : 14.7.13
@nrwl/cypress : 14.7.13
@nrwl/detox : Not Found
@nrwl/devkit : 14.7.13
@nrwl/eslint-plugin-nx : 14.7.13
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 14.7.13
@nrwl/js : 14.7.13
@nrwl/linter : 14.7.13
@nrwl/nest : 14.7.13
@nrwl/next : Not Found
@nrwl/node : 14.7.13
@nrwl/nx-cloud : 14.6.2
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.7.13
@nrwl/web : 14.7.13
@nrwl/workspace : 14.7.13
typescript : 4.7.4

Local workspace plugins:

Community plugins:
@ngneat/transloco: 4.1.1
@ngrx/effects: 12.5.0
@ngrx/entity: 12.4.0
@ngrx/store: 12.5.0
@ngrx/store-devtools: 12.5.0
@rx-angular/cdk: 1.0.0-rc.1
@rx-angular/state: 1.6.0
@rx-angular/template: 1.0.0-beta.32
@storybook/angular: 6.5.12
@testing-library/angular: 11.0.4

@B1Z1 B1Z1 added the type: bug label Oct 4, 2022
@AgentEnder AgentEnder added the scope: core core nx functionality label Oct 4, 2022
@FrozenPandaz
Copy link
Collaborator

Do you perhaps run multiple commands in parallel on CI? Is this an issue locally? It would be good to get a repo that shows this issue so that we can reproduce it.

@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 github-actions bot added the stale label Nov 12, 2022
@lukeramsden
Copy link

We are also seeing this at TransFICC, as @jdpearce can attest to as we've discussed privately.

Error reading '/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: UnexpectedEndOfString in /home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.cache/nx/nxdeps.json at position 159693
    at parseJson (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/src/utils/json.js:23:15)
    at readJsonFile (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/src/utils/fileutils.js:23:37)
    at readCache (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/src/project-graph/nx-deps-cache.js:41:49)
    at readCachedProjectGraph (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/src/project-graph/project-graph.js:18:61)
    at run (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/src/command-line/run.js:167:69)
    at requireCli (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/bin/run-executor.js:17:23)
    at Object.<anonymous> (/home/luke.ramsden/workspace/transficc/transficc/ui/node_modules/.pnpm/nx@15.0.4/node_modules/nx/bin/run-executor.js:12:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.

We don't seem to get it in CI at all (this may be pure chance, or some factor in the environment that makes this possible race condition less likely), but only when running our build locally. I'm trying to determine if we're running multiple nx commands in parallel as part of our build process, will get back to you on that. It might make sense to use file locks to make operations over nxdeps safer though, if you aren't already.

@FrozenPandaz
Copy link
Collaborator

Fixed by #12920

@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 Mar 21, 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

4 participants