feat(ngcc): support marking an in-progress task as unprocessed (#36626)
This commit adds support for stopping processing an in-progress task and moving it back to the list of pending tasks. In a subsequent commit, this will be used to allow ngcc to recover when a worker process crashes in the middle of processing a task. PR Close #36626
This commit is contained in:

committed by
Andrew Kushnir

parent
4c63241b34
commit
4665c35453
@ -117,6 +117,16 @@ export interface TaskQueue {
|
||||
*/
|
||||
markAsFailed(task: Task): void;
|
||||
|
||||
/**
|
||||
* Mark a task as not processed (i.e. add an in-progress task back to the queue).
|
||||
*
|
||||
* This removes the task from the internal list of in-progress tasks and adds it back to the list
|
||||
* of pending tasks.
|
||||
*
|
||||
* @param task The task to mark as not processed.
|
||||
*/
|
||||
markAsUnprocessed(task: Task): void;
|
||||
|
||||
/**
|
||||
* Return a string representation of the task queue (for debugging purposes).
|
||||
*
|
||||
|
@ -63,6 +63,16 @@ export abstract class BaseTaskQueue implements TaskQueue {
|
||||
this.inProgressTasks.delete(task);
|
||||
}
|
||||
|
||||
markAsUnprocessed(task: Task): void {
|
||||
if (!this.inProgressTasks.has(task)) {
|
||||
throw new Error(
|
||||
`Trying to mark task that was not in progress as unprocessed: ${stringifyTask(task)}`);
|
||||
}
|
||||
|
||||
this.inProgressTasks.delete(task);
|
||||
this.tasks.unshift(task);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
const inProgTasks = Array.from(this.inProgressTasks);
|
||||
|
||||
|
Reference in New Issue
Block a user