mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-28 23:37:00 +02:00
fix(core): Ensure cancellation interrupts runner tasks in worker (#19864)
This commit is contained in:
parent
22d5459a72
commit
fac005b165
|
|
@ -72,6 +72,7 @@ describe('JobProcessor', () => {
|
|||
mock(),
|
||||
mock(),
|
||||
executionsConfig,
|
||||
mock(),
|
||||
);
|
||||
|
||||
const result = await jobProcessor.processJob(mock<Job>());
|
||||
|
|
@ -102,6 +103,7 @@ describe('JobProcessor', () => {
|
|||
mock(),
|
||||
manualExecutionService,
|
||||
executionsConfig,
|
||||
mock(),
|
||||
);
|
||||
|
||||
await jobProcessor.processJob(mock<Job>());
|
||||
|
|
@ -141,6 +143,7 @@ describe('JobProcessor', () => {
|
|||
mock(),
|
||||
manualExecutionService,
|
||||
executionsConfig,
|
||||
mock(),
|
||||
);
|
||||
|
||||
const executionId = 'execution-id';
|
||||
|
|
@ -204,6 +207,7 @@ describe('JobProcessor', () => {
|
|||
mock(),
|
||||
manualExecutionService,
|
||||
executionsConfig,
|
||||
mock(),
|
||||
);
|
||||
|
||||
await jobProcessor.processJob(mock<Job>());
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import type {
|
|||
import { BINARY_ENCODING, Workflow, UnexpectedError } from 'n8n-workflow';
|
||||
import type PCancelable from 'p-cancelable';
|
||||
|
||||
import { EventService } from '@/events/event.service';
|
||||
import { getLifecycleHooksForScalingWorker } from '@/execution-lifecycle/execution-lifecycle-hooks';
|
||||
import { ManualExecutionService } from '@/manual-execution.service';
|
||||
import { NodeTypes } from '@/node-types';
|
||||
|
|
@ -44,6 +45,7 @@ export class JobProcessor {
|
|||
private readonly instanceSettings: InstanceSettings,
|
||||
private readonly manualExecutionService: ManualExecutionService,
|
||||
private readonly executionsConfig: ExecutionsConfig,
|
||||
private readonly eventService: EventService,
|
||||
) {
|
||||
this.logger = this.logger.scoped('scaling');
|
||||
}
|
||||
|
|
@ -269,7 +271,13 @@ export class JobProcessor {
|
|||
}
|
||||
|
||||
stopJob(jobId: JobId) {
|
||||
this.runningJobs[jobId]?.run.cancel();
|
||||
const runningJob = this.runningJobs[jobId];
|
||||
if (!runningJob) return;
|
||||
|
||||
const executionId = runningJob.executionId;
|
||||
this.eventService.emit('execution-cancelled', { executionId });
|
||||
|
||||
runningJob.run.cancel();
|
||||
delete this.runningJobs[jobId];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user