mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(core): Account for cancelling an execution with no workers available (#10343)
This commit is contained in:
parent
8728b63aeb
commit
b044e783e7
|
@ -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', () => {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue