mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
fix(core): Fix race condition when resolving post-execute promise (#11360)
This commit is contained in:
@@ -108,6 +108,15 @@ describe('ActiveExecutions', () => {
|
|||||||
expect(activeExecutions.getActiveExecutions().length).toBe(0);
|
expect(activeExecutions.getActiveExecutions().length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Should not try to resolve a post-execute promise for an inactive execution', async () => {
|
||||||
|
// @ts-expect-error Private method
|
||||||
|
const getExecutionSpy = jest.spyOn(activeExecutions, 'getExecution');
|
||||||
|
|
||||||
|
activeExecutions.finalizeExecution('inactive-execution-id', mockFullRunData());
|
||||||
|
|
||||||
|
expect(getExecutionSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
test('Should resolve post execute promise on removal', async () => {
|
test('Should resolve post execute promise on removal', async () => {
|
||||||
const newExecution = mockExecutionData();
|
const newExecution = mockExecutionData();
|
||||||
const executionId = await activeExecutions.add(newExecution);
|
const executionId = await activeExecutions.add(newExecution);
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ export class ActiveExecutions {
|
|||||||
|
|
||||||
/** Resolve the post-execution promise in an execution. */
|
/** Resolve the post-execution promise in an execution. */
|
||||||
finalizeExecution(executionId: string, fullRunData?: IRun) {
|
finalizeExecution(executionId: string, fullRunData?: IRun) {
|
||||||
|
if (!this.has(executionId)) return;
|
||||||
const execution = this.getExecution(executionId);
|
const execution = this.getExecution(executionId);
|
||||||
execution.postExecutePromise.resolve(fullRunData);
|
execution.postExecutePromise.resolve(fullRunData);
|
||||||
this.logger.debug('Execution finalized', { executionId });
|
this.logger.debug('Execution finalized', { executionId });
|
||||||
|
|||||||
Reference in New Issue
Block a user