Skip to content

Commit a07663a

Browse files
fix(ngcc): display unlocker process output in sync mode
The change in e041ac6 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 nodejs/node#3596 (comment). 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.
1 parent e22f60b commit a07663a

File tree

1 file changed

+9
-8
lines changed
  • packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process

1 file changed

+9
-8
lines changed

packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ export class LockFileWithChildProcess implements LockFile {
8282
this.logger.debug('Forking unlocker child-process');
8383
const logLevel =
8484
this.logger.level !== undefined ? this.logger.level.toString() : LogLevel.info.toString();
85-
86-
const unlocker = fork(this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel], {
87-
detached: true,
88-
stdio: 'pipe',
89-
}) as ChildProcessByStdio<Writable, Readable, Readable>;
90-
unlocker.stdout.on('data', data => process.stdout.write(data));
91-
unlocker.stderr.on('data', data => process.stderr.write(data));
92-
85+
const isWindows = process.platform === 'win32';
86+
const unlocker = fork(
87+
this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel],
88+
{detached: true, stdio: isWindows ? 'pipe' : 'inherit'}) as
89+
ChildProcessByStdio<Writable, Readable, Readable>;
90+
if (isWindows) {
91+
unlocker.stdout.on('data', process.stdout.write.bind(process.stdout));
92+
unlocker.stderr.on('data', process.stderr.write.bind(process.stderr));
93+
}
9394
return unlocker;
9495
}
9596
}

0 commit comments

Comments
 (0)