mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-03 08:57:28 -08:00
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
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:
parent
8fbad74ab6
commit
b05d435199
|
@ -3,7 +3,7 @@ import { useRouter } from 'vue-router';
|
||||||
import { createPinia, setActivePinia } from 'pinia';
|
import { createPinia, setActivePinia } from 'pinia';
|
||||||
import type { PushMessage, PushPayload } from '@n8n/api-types';
|
import type { PushMessage, PushPayload } from '@n8n/api-types';
|
||||||
import { mock } from 'vitest-mock-extended';
|
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 { usePushConnection } from '@/composables/usePushConnection';
|
||||||
import { usePushConnectionStore } from '@/stores/pushConnection.store';
|
import { usePushConnectionStore } from '@/stores/pushConnection.store';
|
||||||
|
@ -61,6 +61,7 @@ describe('usePushConnection()', () => {
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
|
pushConnection.pushMessageQueue.value = [];
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('initialize()', () => {
|
describe('initialize()', () => {
|
||||||
|
@ -221,5 +222,32 @@ describe('usePushConnection()', () => {
|
||||||
expect(spy).toHaveBeenCalledWith(executionId);
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -155,7 +155,7 @@ export function usePushConnection({ router }: { router: ReturnType<typeof useRou
|
||||||
// The data is not for the currently active execution or
|
// The data is not for the currently active execution or
|
||||||
// we do not have the execution id yet.
|
// we do not have the execution id yet.
|
||||||
if (isRetry !== true) {
|
if (isRetry !== true) {
|
||||||
queuePushMessage(event as unknown as PushMessage, retryAttempts);
|
queuePushMessage(receivedData, retryAttempts);
|
||||||
}
|
}
|
||||||
return false;
|
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
|
// The workflow which did finish execution did either not get started
|
||||||
// by this session or we do not have the execution id yet.
|
// by this session or we do not have the execution id yet.
|
||||||
if (isRetry !== true) {
|
if (isRetry !== true) {
|
||||||
queuePushMessage(event as unknown as PushMessage, retryAttempts);
|
queuePushMessage(receivedData, retryAttempts);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue