Skip to content

Commit

Permalink
fix(core): Account for cancelling an execution with no workers availa…
Browse files Browse the repository at this point in the history
…ble (#10343)
  • Loading branch information
ivov authored Aug 12, 2024
1 parent 8728b63 commit b044e78
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/cli/src/scaling/__tests__/scaling.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@ describe('ScalingService', () => {
expect(jobs).toHaveLength(1);
expect(jobs.at(0)?.id).toBe('123');
});

it('should filter out `null` in Redis response', async () => {
/**
* Arrange
*/
const scalingService = new ScalingService(mock(), mock(), mock());
await scalingService.setupQueue();
// @ts-expect-error - Untyped but possible Redis response
queue.getJobs.mockResolvedValue([mock<Job>(), null]);

/**
* Act
*/
const jobs = await scalingService.findJobsByStatus(['waiting']);

/**
* Assert
*/
expect(jobs).toHaveLength(1);
});
});

describe('stopJob', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/scaling/scaling.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export class ScalingService {
}

async findJobsByStatus(statuses: JobStatus[]) {
return await this.queue.getJobs(statuses);
const jobs = await this.queue.getJobs(statuses);

return jobs.filter((job) => job !== null);
}

async stopJob(job: Job) {
Expand Down

0 comments on commit b044e78

Please sign in to comment.