refactor(ngcc): add debug messages to help with debugging in parallel mode (#34437)

PR Close #34437
This commit is contained in:
George Kalpakas
2019-12-05 21:02:57 +02:00
committed by Kara Erickson
parent 5cecd97493
commit cd8a837956
4 changed files with 35 additions and 11 deletions

View File

@ -39,7 +39,7 @@ export class ClusterExecutor implements Executor {
return master.run();
} else {
// This process is a cluster worker.
const worker = new ClusterWorker(createCompileFn);
const worker = new ClusterWorker(this.logger, createCompileFn);
return worker.run();
}
}

View File

@ -10,7 +10,9 @@
import * as cluster from 'cluster';
import {Logger} from '../../logging/logger';
import {CompileFn, CreateCompileFn} from '../api';
import {stringifyTask} from '../utils';
import {MessageToWorker} from './api';
import {sendMessageToMaster} from './utils';
@ -23,7 +25,7 @@ import {sendMessageToMaster} from './utils';
export class ClusterWorker {
private compile: CompileFn;
constructor(createCompileFn: CreateCompileFn) {
constructor(private logger: Logger, createCompileFn: CreateCompileFn) {
if (cluster.isMaster) {
throw new Error('Tried to instantiate `ClusterWorker` on the master process.');
}
@ -38,10 +40,12 @@ export class ClusterWorker {
try {
switch (msg.type) {
case 'process-task':
this.logger.debug(
`[Worker #${cluster.worker.id}] Processing task: ${stringifyTask(msg.task)}`);
return this.compile(msg.task);
default:
throw new Error(
`Invalid message received on worker #${cluster.worker.id}: ${JSON.stringify(msg)}`);
`[Worker #${cluster.worker.id}] Invalid message received: ${JSON.stringify(msg)}`);
}
} catch (err) {
sendMessageToMaster({

View File

@ -274,6 +274,8 @@ export function mainNgcc(
`Failed to compile entry-point ${entryPoint.name} due to compilation errors:\n${errors}`);
}
logger.debug(` Successfully compiled ${entryPoint.name} : ${formatProperty}`);
onTaskCompleted(task, TaskProcessingOutcome.Processed);
};
};