fix(core): fix issue with summary missing outputs (#30819)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

Some tasks end but don't have their terminal outputs printed. When that
is the case, an error occurred where task terminal output was attempted
to be printed but did not exist.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Tracking terminal outputs is restored to being part of printing task
terminal output.. and printing task terminal output is guaranteed when
pseudo terminal is used.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jason Jean 2025-04-22 21:47:42 -04:00 committed by GitHub
parent 59d92af548
commit 16fc5517f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 10 deletions

View File

@ -224,6 +224,13 @@ export class ForkedProcessTaskRunner {
}
this.pseudoTerminals.delete(pseudoTerminal);
this.processes.delete(p);
if (!streamOutput) {
this.options.lifeCycle.printTaskTerminalOutput(
task,
code === 0 ? 'success' : 'failure',
terminalOutput
);
}
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
});

View File

@ -58,23 +58,22 @@ export function getTuiTerminalSummaryLifeCycle({
};
lifeCycle.printTaskTerminalOutput = (task, taskStatus, terminalOutput) => {
taskIdsInOrderOfCompletion.push(task.id);
tasksToTerminalOutputs[task.id] = { terminalOutput, taskStatus };
};
lifeCycle.setTaskStatus = (taskId, taskStatus) => {
if (taskStatus === NativeTaskStatus.Stopped) {
totalStoppedTasks++;
taskIdsInOrderOfCompletion.push(taskId);
}
};
lifeCycle.endTasks = (taskResults) => {
for (let t of taskResults) {
for (const { task, status } of taskResults) {
totalCompletedTasks++;
inProgressTasks.delete(t.task.id);
taskIdsInOrderOfCompletion.push(t.task.id);
inProgressTasks.delete(task.id);
switch (t.status) {
switch (status) {
case 'remote-cache':
case 'local-cache':
case 'local-cache-kept-existing':
@ -86,7 +85,7 @@ export function getTuiTerminalSummaryLifeCycle({
break;
case 'failure':
totalFailedTasks++;
failedTasks.add(t.task.id);
failedTasks.add(task.id);
break;
}
}

View File

@ -668,8 +668,16 @@ export class TaskOrchestrator {
// and release the threads
await this.scheduleNextTasksAndReleaseThreads();
if (this.initializingTaskIds.has(task.id)) {
// Hold the thread forever
await new Promise(() => {});
await new Promise<void>((res) => {
runningTask.onExit((code) => {
if (!this.tuiEnabled) {
if (code > 128) {
process.exit(code);
}
}
res();
});
});
}
return runningTask;
}
@ -722,8 +730,16 @@ export class TaskOrchestrator {
});
await this.scheduleNextTasksAndReleaseThreads();
if (this.initializingTaskIds.has(task.id)) {
// Hold the thread forever
await new Promise(() => {});
await new Promise<void>((res) => {
childProcess.onExit((code) => {
if (!this.tuiEnabled) {
if (code > 128) {
process.exit(code);
}
}
res();
});
});
}
return childProcess;