fix(ngcc): display unlocker process output in sync mode (#36637)
The change in e041ac6f0d
to support sending unlocker process output to the main ngcc
console output prevents messages require that the main process
relinquishes the event-loop to allow the `stdout.on()` handler to
run. This results in none of the messages being written when ngcc
is run in `--no-async` mode, and some messages failing to be
written if the main process is killed (e.g. ctrl-C).
It appears that the problem with Windows and detached processes
is known - see https://github.com/nodejs/node/issues/3596#issuecomment-250890218.
But in the meantime, this commit is a workaround, where non-Windows
`inherit` the main process `stdout` while on Windows it reverts
to the async handler approach, which is better than nothing.
PR Close #36637
This commit is contained in:
parent
2ed7146393
commit
cabf997933
|
@ -82,14 +82,14 @@ export class LockFileWithChildProcess implements LockFile {
|
|||
this.logger.debug('Forking unlocker child-process');
|
||||
const logLevel =
|
||||
this.logger.level !== undefined ? this.logger.level.toString() : LogLevel.info.toString();
|
||||
|
||||
const unlocker = fork(this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel], {
|
||||
detached: true,
|
||||
stdio: 'pipe',
|
||||
}) as ChildProcessByStdio<Writable, Readable, Readable>;
|
||||
unlocker.stdout.on('data', data => process.stdout.write(data));
|
||||
unlocker.stderr.on('data', data => process.stderr.write(data));
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
const unlocker = fork(
|
||||
this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel],
|
||||
{detached: true, stdio: isWindows ? 'pipe' : 'inherit'});
|
||||
if (isWindows) {
|
||||
unlocker.stdout?.on('data', process.stdout.write.bind(process.stdout));
|
||||
unlocker.stderr?.on('data', process.stderr.write.bind(process.stderr));
|
||||
}
|
||||
return unlocker;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue