Skip to content

Commit

Permalink
fix(core): ensure output paths returned are unique
Browse files Browse the repository at this point in the history
It is possible for users to define multiple duplicate outputs. This is leading to fs related issues like `ENOTEMPTY: directory not empty, rmdir`. The reason this occurs is that the src will tried to be copied to the cached directory in parallel for all output paths and is the reason why these errors are seen sporadically. By ensuring output paths are unique, we only ever copy one path which resolves this issue.

fixes #17277, ##16337
  • Loading branch information
agdimech authored and AgentEnder committed Jun 4, 2024
1 parent c002b54 commit 4ff189a
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/nx/src/tasks-runner/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,24 @@ export function getOutputsForTargetAndConfiguration(
if (targetConfiguration?.outputs) {
validateOutputs(targetConfiguration.outputs);

return targetConfiguration.outputs
.map((output: string) => {
return interpolate(output, {
projectRoot: node.data.root,
projectName: node.name,
project: { ...node.data, name: node.name }, // this is legacy
options,
});
})
.filter(
(output) =>
!!output && !output.match(/{(projectRoot|workspaceRoot|(options.*))}/)
);
const result = new Set<string>();
for (const output of targetConfiguration.outputs) {
const interpolatedOutput = interpolate(output, {
projectRoot: node.data.root,
projectName: node.name,
project: { ...node.data, name: node.name }, // this is legacy
options,
});
if (
!!interpolatedOutput &&
!interpolatedOutput.match(
/{(projectRoot|workspaceRoot|(options.*))}/
)
) {
result.add(interpolatedOutput);
}
}
return Array.from(result);
}

// Keep backwards compatibility in case `outputs` doesn't exist
Expand Down

0 comments on commit 4ff189a

Please sign in to comment.