Skip to content

Commit

Permalink
fix(worker): change active event typing
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored and manast committed Jun 22, 2021
1 parent 8d40ddb commit 220b4f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/classes/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import { isRedisInstance, delay } from '../utils';
export const clientCommandMessageReg = /ERR unknown command ['`]\s*client\s*['`]/;

export declare interface Worker {
on(
event: 'active',
listener: (job: Job, result: null, prev: string) => void,
): this;
on(event: 'active', listener: (job: Job, prev: string) => void): this;
on(event: 'completed', listener: (job: Job) => void): this;
on(event: 'drained', listener: () => void): this;
on(event: 'error', listener: (failedReason: Error) => void): this;
Expand Down Expand Up @@ -349,8 +346,7 @@ export class Worker<
}
};

// TODO: how to cancel the processing? (null -> job.cancel() => throw CancelError()void)
this.emit('active', job, null, 'waiting');
this.emit('active', job, 'waiting');

lockExtender();
try {
Expand Down
3 changes: 1 addition & 2 deletions src/test/test_sandboxed_process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ describe('sandboxed process', () => {

// await this After we've added the job
const onJobActive = new Promise<void>(resolve => {
worker.on('active', (job, result, prev) => {
expect(result).to.be.null;
worker.on('active', (job, prev) => {
expect(prev).to.be.equal('waiting');
resolve();
});
Expand Down

0 comments on commit 220b4f6

Please sign in to comment.