nx
nx copied to clipboard
Native hasher unable to find project created by plugin
Current Behavior
We have a plugin that add's projects based on an custom file we have, when we run nx show project <project name> it outputs fine, but when we try to run one of the projects targets the native hasher crashes.
Expected Behavior
The native hasher to not crash and the target to run.
GitHub Repo
No response
Steps to Reproduce
Nx Report
nx (global) : 18.0.2
nx : 18.0.7
@nx/js : 18.0.7
@nx/jest : 18.0.7
@nx/linter : 18.0.7
@nx/eslint : 18.0.7
@nx/workspace : 18.0.7
@nx/devkit : 18.0.7
@nx/eslint-plugin : 18.0.7
@nx/nest : 18.0.7
@nx/next : 18.0.7
@nx/node : 18.0.7
@nx/playwright : 18.0.7
@nx/plugin : 18.0.7
@nx/react : 18.0.7
@nrwl/tao : 18.0.7
@nx/web : 18.0.7
@nx/webpack : 18.0.7
typescript : 5.3.3
---------------------------------------
Community plugins:
@jscutlery/semver : 5.0.0
@nx-extend/changelog-notify : 6.0.0
@nx-extend/e2e-runner : 9.0.0
@nx-extend/firebase-hosting : 6.0.7
@nx-extend/gcp-cloud-run : 8.0.0
@nx-extend/gcp-deployment-manager : 7.0.0
@nx-extend/gcp-functions : 12.0.1
@nx-extend/gcp-secrets : 8.0.0
@nx-extend/gcp-storage : 7.0.0
@nx-extend/playwright : 7.0.0
@nx-extend/pulumi : 5.0.3
@nx-extend/strapi : 9.0.1
@nx-extend/terraform : 5.0.0
@nx-extend/translations : 12.0.0
@nx-extend/vercel : 7.0.0
Failure Logs
[NX Daemon Server] - 2024-03-07T15:31:18.279Z - Started listening on: /var/folders/q3/m6r3ggwn63z7vcs3m90l58y40000gn/T/90c8ad929e543f037f15/d.sock
[NX Daemon Server] - 2024-03-07T15:31:18.282Z - [WATCHER]: Subscribed to changes within: <workspace root> (native)
[NX Daemon Server] - 2024-03-07T15:31:18.293Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-03-07T15:31:18.294Z - Established a connection. Number of open connections: 2
[NX Daemon Server] - 2024-03-07T15:31:18.295Z - Closed a connection. Number of open connections: 1
[NX Daemon Server] - 2024-03-07T15:31:18.296Z - [REQUEST]: Client Request for Project Graph Received
[NX Daemon Server] - 2024-03-07T15:31:18.327Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX Daemon Server] - 2024-03-07T15:31:18.327Z - [REQUEST]:
[NX Daemon Server] - 2024-03-07T15:31:18.328Z - [REQUEST]:
[NX Daemon Server] - 2024-03-07T15:31:18.872Z - [REQUEST]: Responding to the client. project-graph
[NX Daemon Server] - 2024-03-07T15:31:18.873Z - Time taken for 'total for creating and serializing project graph' 576.0004159994423ms
[NX Daemon Server] - 2024-03-07T15:31:18.878Z - Done responding to the client project-graph
[NX Daemon Server] - 2024-03-07T15:31:18.878Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 576. Response time: 6.
<workspace root>/node_modules/nx/src/hasher/native-task-hasher-impl.js:33
const hashes = this.hasher.hashPlans(plans, env);
^
Error: project <project name> not found
at NativeTaskHasherImpl.hashTasks (<workspace root>/node_modules/nx/src/hasher/native-task-hasher-impl.js:33:36)
at InProcessTaskHasher.hashTasks (<workspace root>/node_modules/nx/src/hasher/task-hasher.js:53:50)
at handleHashTasks (<workspace root>/node_modules/nx/src/daemon/server/handle-hash-tasks.js:20:56)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at handleResult (<workspace root>/node_modules/nx/src/daemon/server/server.js:110:16)
at handleMessage (<workspace root>/node_modules/nx/src/daemon/server/server.js:84:9)
at <workspace root>/node_modules/nx/src/daemon/server/server.js:45:9 {
code: 'GenericFailure'
}
Package Manager Version
No response
Operating System
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
No response
Any update here?
@FrozenPandaz / @AgentEnder / @ anyone
Any update? This makes our plugin not usable and we can't use any of the projects that it adds.
What does the plugin code look like? Without a reproduction thia may be hard to debug as even project.json files are loaded by a plugin (same way the custom plugins work), and I've not seen similar issues.
Note that the graph etc all work (the nx show project <project>, it's just the demon that cannot find it.
Full code of the plugin:
import { readJsonFile } from 'nx/src/utils/fileutils'
import { CreateNodes, CreateNodesContext } from 'nx/src/utils/nx-plugin'
import { resolve } from 'path'
export const createNodes: CreateNodes = [
'**/sites/site.*.json',
(projectConfigurationFile: string, options, context: CreateNodesContext) => {
const projectConfiguration = readJsonFile(resolve(context.workspaceRoot, projectConfigurationFile)) as {
name: string
domain: string
vercel: {
projectId: string
envVars: object
}
}
const cmsProject = `sites-cms-${projectConfiguration.name}`
const webProject = `sites-web-${projectConfiguration.name}`
const projectNameWithUnderscores = projectConfiguration.name.replace(/-/g, '_')
return {
projects: {
[cmsProject]: {
name: cmsProject,
type: 'app',
targets: {
build: {
cache: false,
executor: '@nx-extend/strapi:build',
outputs: [
'{options.outputPath}'
],
inputs: [
{
'fileset': '{workspaceRoot}/libs/cms/**'
}
],
options: {
root: 'libs/sites/strapi',
outputPath: `dist/sites/cms/${projectConfiguration.name}`,
tsConfig: 'libs/sites/strapi/tsconfig.json',
envVars: {}
},
configurations: {
production: {
production: true,
envVars: {
URL: `https://cms.${projectConfiguration.domain}`
}
}
}
},
deploy: 'REDACTED'
},
tags: [
'project=sites',
'service=cms',
'resource=gcp-cloud-run'
]
},
'libs/sites/next': {
name: 'sites-next',
targets: {
build: {
configurations: {
[projectConfiguration.name]: {
outputPath: `dist/sites/web/${projectConfiguration.name}`
}
}
}
}
},
[webProject]: {
name: webProject,
type: 'app',
targets: {
'vercel-build': {
cache: false,
executor: '@nx-extend/vercel:build',
outputs: [],
defaultConfiguration: 'production',
dependsOn: [
'{workspaceRoot}/libs/sites/next/**/*'
],
inputs: [
{
fileset: '{workspaceRoot}/libs/web/**'
},
{
runtime: 'date'
}
],
options: 'REDACTED',
configurations: {
development: {},
production: {}
}
},
'vercel-deploy': 'REDACTED',
deploy: {
executor: 'nx:run-commands',
options: {
commands: [
`nx vercel-build ${webProject} --configuration=production`,
`nx vercel-deploy ${webProject} --configuration=production`
],
parallel: false
}
}
},
tags: [
'project=sites',
'service=web',
'resource=vercel'
]
}
}
}
}
]
@AgentEnder bump, we would like to be able to deploy again.
Hey @TriPSs - nothing looks overtly wrong in the plugin code... Can you provide a github repo that exhibits the behavior? As I said, all of the project configurations stuff is written this way too, nothing special about local plugins really. It would help to be able to better debug your issue.
@AgentEnder create the repo here. After cloning and installing deps you should run nx build sites-web-belgium, that should eventually just run echo "build".
If you where to check the .nx/project-graph.json you can actually see it does create sites-web-belgium and sites-cms-belgium
@AgentEnder I think I found out why it happens, CreateNodesResult says that the root is optional but once I provide a root (and it's the only file there) it seems to work correctly.
Since we have this config file 10 times in one directory it's still not working correclty, as the interface says defining the root is optional I would expect the native hasher to maybe just not hash if the root is not defined or does not exist.
This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏
A repo was provided: https://github.com/TriPSs/nx-hasher-issue
Any update here?
Updated to the latest version of Nx (also to CreateNodesV2), ~~now it just says the project does not exist, demon log is empty, when you look at the generated project graph the project does exist.~~
Previous errors still exist.
Any update?
Any update?
@AgentEnder ?