mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-23 11:44:06 -08:00
fix(core): Fix race condition when resolving post-execute promise (#11360)
This commit is contained in:
parent
c078a516be
commit
4f1816e03d
|
@ -108,6 +108,15 @@ describe('ActiveExecutions', () => {
|
|||
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 () => {
|
||||
const newExecution = mockExecutionData();
|
||||
const executionId = await activeExecutions.add(newExecution);
|
||||
|
|
|
@ -154,6 +154,7 @@ export class ActiveExecutions {
|
|||
|
||||
/** Resolve the post-execution promise in an execution. */
|
||||
finalizeExecution(executionId: string, fullRunData?: IRun) {
|
||||
if (!this.has(executionId)) return;
|
||||
const execution = this.getExecution(executionId);
|
||||
execution.postExecutePromise.resolve(fullRunData);
|
||||
this.logger.debug('Execution finalized', { executionId });
|
||||
|
|
Loading…
Reference in a new issue