fix(editor): Fix partial executions not working due to broken push message queue and race conditions (#11798)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions

This commit is contained in:
Danny Martini 2024-11-20 12:07:05 +01:00 committed by GitHub
parent 8fbad74ab6
commit b05d435199
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import { useRouter } from 'vue-router';
import { createPinia, setActivePinia } from 'pinia';
import type { PushMessage, PushPayload } from '@n8n/api-types';
import { mock } from 'vitest-mock-extended';
import type { WorkflowOperationError } from 'n8n-workflow';
import type { ITaskData, WorkflowOperationError } from 'n8n-workflow';
import { usePushConnection } from '@/composables/usePushConnection';
import { usePushConnectionStore } from '@/stores/pushConnection.store';
@ -61,6 +61,7 @@ describe('usePushConnection()', () => {
afterEach(() => {
vi.restoreAllMocks();
pushConnection.pushMessageQueue.value = [];
});
describe('initialize()', () => {
@ -221,5 +222,32 @@ describe('usePushConnection()', () => {
expect(spy).toHaveBeenCalledWith(executionId);
});
});
describe('nodeExecuteAfter', async () => {
it("enqueues messages if we don't have the active execution id yet", async () => {
uiStore.isActionActive.workflowRunning = true;
const event: PushMessage = {
type: 'nodeExecuteAfter',
data: {
executionId: '1',
nodeName: 'foo',
data: {} as ITaskData,
},
};
expect(pushConnection.retryTimeout.value).toBeNull();
expect(pushConnection.pushMessageQueue.value.length).toBe(0);
const result = await pushConnection.pushMessageReceived(event);
expect(result).toBe(false);
expect(pushConnection.pushMessageQueue.value).toHaveLength(1);
expect(pushConnection.pushMessageQueue.value).toContainEqual({
message: event,
retriesLeft: 5,
});
expect(pushConnection.retryTimeout).not.toBeNull();
});
});
});
});

View file

@ -155,7 +155,7 @@ export function usePushConnection({ router }: { router: ReturnType<typeof useRou
// The data is not for the currently active execution or
// we do not have the execution id yet.
if (isRetry !== true) {
queuePushMessage(event as unknown as PushMessage, retryAttempts);
queuePushMessage(receivedData, retryAttempts);
}
return false;
}
@ -200,7 +200,7 @@ export function usePushConnection({ router }: { router: ReturnType<typeof useRou
// The workflow which did finish execution did either not get started
// by this session or we do not have the execution id yet.
if (isRetry !== true) {
queuePushMessage(event as unknown as PushMessage, retryAttempts);
queuePushMessage(receivedData, retryAttempts);
}
return false;
}