refactor(ngcc): add debug messages to help with debugging in parallel mode (#34437)
PR Close #34437
This commit is contained in:

committed by
Kara Erickson

parent
b1d4c58b81
commit
e5d992c175
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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({
|
||||
|
Reference in New Issue
Block a user