This reverts commit c3709b2b84057166cbb94d3ce5cfc3de17252d35. The change can result in tasks hanging when underlying processes are not properly managed (can be processes created from third-party plugins or user's code). A hanging task is a more serious issue than what this was originally solving. We'll revisit this soon. <!-- 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 --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
9b7a797e8e
commit
b0d4ac64d7
@ -338,19 +338,19 @@ export class ForkedProcessTaskRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let outWithErr = [];
|
let outWithErr = [];
|
||||||
let exitCode;
|
p.stdout.on('data', (chunk) => {
|
||||||
let stdoutHasEnded = false;
|
outWithErr.push(chunk.toString());
|
||||||
let stderrHasEnded = false;
|
});
|
||||||
let processHasExited = false;
|
p.stderr.on('data', (chunk) => {
|
||||||
|
outWithErr.push(chunk.toString());
|
||||||
|
});
|
||||||
|
|
||||||
const handleProcessEnd = () => {
|
p.on('exit', (code, signal) => {
|
||||||
// ensure process has exited and both stdout and stderr have ended before we pass along the logs
|
this.processes.delete(p);
|
||||||
// if we only wait for the process to exit, we might miss some logs as stdout and stderr might still be streaming
|
if (code === null) code = signalToCode(signal);
|
||||||
if (stdoutHasEnded && stderrHasEnded && processHasExited) {
|
|
||||||
// we didn't print any output as we were running the command
|
// we didn't print any output as we were running the command
|
||||||
// print all the collected output|
|
// print all the collected output|
|
||||||
const terminalOutput = outWithErr.join('');
|
const terminalOutput = outWithErr.join('');
|
||||||
const code = exitCode;
|
|
||||||
|
|
||||||
if (!streamOutput) {
|
if (!streamOutput) {
|
||||||
this.options.lifeCycle.printTaskTerminalOutput(
|
this.options.lifeCycle.printTaskTerminalOutput(
|
||||||
@ -361,30 +361,6 @@ export class ForkedProcessTaskRunner {
|
|||||||
}
|
}
|
||||||
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
||||||
res({ code, terminalOutput });
|
res({ code, terminalOutput });
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
p.stdout.on('data', (chunk) => {
|
|
||||||
outWithErr.push(chunk.toString());
|
|
||||||
});
|
|
||||||
p.stdout.on('end', () => {
|
|
||||||
stdoutHasEnded = true;
|
|
||||||
handleProcessEnd();
|
|
||||||
});
|
|
||||||
p.stderr.on('data', (chunk) => {
|
|
||||||
outWithErr.push(chunk.toString());
|
|
||||||
});
|
|
||||||
p.stderr.on('end', () => {
|
|
||||||
stderrHasEnded = true;
|
|
||||||
handleProcessEnd();
|
|
||||||
});
|
|
||||||
|
|
||||||
p.on('exit', (code, signal) => {
|
|
||||||
this.processes.delete(p);
|
|
||||||
if (code === null) code = signalToCode(signal);
|
|
||||||
exitCode = code;
|
|
||||||
processHasExited = true;
|
|
||||||
handleProcessEnd();
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user