Skip to content

Commit

Permalink
fix: use emit instead of console.error
Browse files Browse the repository at this point in the history
  • Loading branch information
stansv committed Jan 15, 2020
1 parent 05750db commit d5df6f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/classes/queue-scheduler.ts
Expand Up @@ -29,9 +29,7 @@ export class QueueScheduler extends QueueBase {
constructor(protected name: string, opts: QueueSchedulerOptions = {}) {
super(name, { maxStalledCount: 1, stalledInterval: 30000, ...opts });

this.run().catch(error => {
console.error(error);
});
this.run().catch(this.emit.bind(this));
}

private async run() {
Expand Down
4 changes: 1 addition & 3 deletions src/classes/queue.ts
Expand Up @@ -29,9 +29,7 @@ export class Queue<T = any> extends QueueGetters {
get(opts, 'streams.events.maxLen', 10000),
),
)
.catch(error => {
console.error(error);
});
.catch(this.emit.bind(this));
}

get defaultJobOptions() {
Expand Down
6 changes: 2 additions & 4 deletions src/classes/worker.ts
Expand Up @@ -81,9 +81,7 @@ export class Worker<T = any> extends QueueBase {
}
this.timerManager = new TimerManager();

this.run().catch(error => {
console.error(error);
});
this.run().catch(this.emit.bind(this));
}

get repeat() {
Expand Down Expand Up @@ -256,7 +254,7 @@ export class Worker<T = any> extends QueueBase {
// FIXME if result = 0 (missing lock), reject processFn promise to take next job?
}
} catch (error) {
console.error('Error extending lock ', error);
this.emit.bind(this)(error);
// Somehow tell the worker this job should stop processing...
}
},
Expand Down

0 comments on commit d5df6f5

Please sign in to comment.