fix(core): Do not load ScalingService in regular mode (no-changelog) (#10333)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-08-08 17:35:17 +02:00
committed by GitHub
parent eef4fb8bb4
commit 1869c396f3
6 changed files with 20 additions and 19 deletions

View File

@@ -6,15 +6,16 @@ import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.err
import { MissingExecutionStopError } from '@/errors/missing-execution-stop.error';
import type { ActiveExecutions } from '@/ActiveExecutions';
import type { IExecutionResponse } from '@/Interfaces';
import type { ScalingService } from '@/scaling/scaling.service';
import { ScalingService } from '@/scaling/scaling.service';
import type { WaitTracker } from '@/WaitTracker';
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
import type { ExecutionRequest } from '@/executions/execution.types';
import type { ConcurrencyControlService } from '@/concurrency/concurrency-control.service';
import type { Job } from '@/scaling/types';
import { mockInstance } from '@test/mocking';
describe('ExecutionService', () => {
const scalingService = mock<ScalingService>();
const scalingService = mockInstance(ScalingService);
const activeExecutions = mock<ActiveExecutions>();
const executionRepository = mock<ExecutionRepository>();
const waitTracker = mock<WaitTracker>();
@@ -23,7 +24,6 @@ describe('ExecutionService', () => {
const executionService = new ExecutionService(
mock(),
mock(),
scalingService,
activeExecutions,
executionRepository,
mock(),

View File

@@ -1,4 +1,4 @@
import { Service } from 'typedi';
import { Container, Service } from 'typedi';
import { GlobalConfig } from '@n8n/config';
import { validate as jsonSchemaValidate } from 'jsonschema';
import type {
@@ -24,7 +24,6 @@ import type {
IWorkflowExecutionDataProcess,
} from '@/Interfaces';
import { NodeTypes } from '@/NodeTypes';
import { ScalingService } from '@/scaling/scaling.service';
import type { ExecutionRequest, ExecutionSummaries, StopResult } from './execution.types';
import { WorkflowRunner } from '@/WorkflowRunner';
import type { IGetExecutionsQueryFilter } from '@db/repositories/execution.repository';
@@ -85,7 +84,6 @@ export class ExecutionService {
constructor(
private readonly globalConfig: GlobalConfig,
private readonly logger: Logger,
private readonly scalingService: ScalingService,
private readonly activeExecutions: ActiveExecutions,
private readonly executionRepository: ExecutionRepository,
private readonly workflowRepository: WorkflowRepository,
@@ -471,12 +469,14 @@ export class ExecutionService {
this.waitTracker.stopExecution(execution.id);
}
const jobs = await this.scalingService.findJobsByStatus(['active', 'waiting']);
const { ScalingService } = await import('@/scaling/scaling.service');
const scalingService = Container.get(ScalingService);
const jobs = await scalingService.findJobsByStatus(['active', 'waiting']);
const job = jobs.find(({ data }) => data.executionId === execution.id);
if (job) {
await this.scalingService.stopJob(job);
await scalingService.stopJob(job);
} else {
this.logger.debug('Job to stop not in queue', { executionId: execution.id });
}