Skip to content

Commit 4202f2c

Browse files
authored
fix(core): prevent task hashing when project graph has errors (#34116)
## Current Behavior When the daemon encounters a project graph error during task hashing, it extracts the partial project graph from the error and continues hashing tasks. This can produce incorrect hashes since the graph is incomplete. ## Expected Behavior The error should be thrown immediately, preventing any hashing attempts with an invalid project graph. This ensures we don't produce incorrect task hashes that could lead to cache issues. ## Related Issue(s) N/A - Bug fix discovered during development
1 parent 323554b commit 4202f2c

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

packages/nx/src/daemon/server/handle-hash-tasks.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Task, TaskGraph } from '../../config/task-graph';
22
import { getCachedSerializedProjectGraphPromise } from './project-graph-incremental-recomputation';
33
import { InProcessTaskHasher } from '../../hasher/task-hasher';
44
import { readNxJson } from '../../config/configuration';
5-
import { DaemonProjectGraphError } from '../../project-graph/error-types';
65

76
/**
87
* We use this not to recreated hasher for every hash operation
@@ -18,21 +17,11 @@ export async function handleHashTasks(payload: {
1817
taskGraph: TaskGraph;
1918
cwd: string;
2019
}) {
21-
const {
22-
error,
23-
projectGraph: _graph,
24-
allWorkspaceFiles,
25-
fileMap,
26-
rustReferences,
27-
} = await getCachedSerializedProjectGraphPromise();
20+
const { error, projectGraph, allWorkspaceFiles, fileMap, rustReferences } =
21+
await getCachedSerializedProjectGraphPromise();
2822

29-
let projectGraph = _graph;
3023
if (error) {
31-
if (error instanceof DaemonProjectGraphError) {
32-
projectGraph = error.projectGraph;
33-
} else {
34-
throw error;
35-
}
24+
throw error;
3625
}
3726

3827
const nxJson = readNxJson();

0 commit comments

Comments
 (0)