Skip to content

Commit

Permalink
Update isTaskFlushedError to worker across workers
Browse files Browse the repository at this point in the history
  • Loading branch information
stwiname committed Nov 12, 2024
1 parent 58d3609 commit 864a821
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/node-core/src/utils/autoQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ export interface IQueue {
}

export class TaskFlushedError extends Error {
readonly name = 'TaskFlushedError';

constructor(queueName = 'Auto') {
super(`This task was flushed from the ${queueName} queue before completing`);
}
}

export function isTaskFlushedError(e: any): e is TaskFlushedError {
return e instanceof TaskFlushedError;
return (e as TaskFlushedError)?.name === 'TaskFlushedError';
}

export class Queue<T> implements IQueue {
Expand Down Expand Up @@ -121,7 +123,12 @@ export class AutoQueue<T> implements IQueue {
* @param {number} [taskTimeoutSec=900] - A timeout for tasks to complete in. Units are seconds. Align with nodeConfig process timeout.
* @param {string} [name] - A name for the queue to help with debugging
* */
constructor(capacity?: number, public concurrency = 1, private taskTimeoutSec = 900, private name = 'Auto') {
constructor(
capacity?: number,
public concurrency = 1,
private taskTimeoutSec = 900,
private name = 'Auto'
) {
this.queue = new Queue<Action<T>>(capacity);
}

Expand Down

0 comments on commit 864a821

Please sign in to comment.