mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Add node ID to log streaming events (#16313)
This commit is contained in:
@@ -13,6 +13,7 @@ export interface EventPayloadNode extends AbstractEventPayload {
|
||||
msg?: string;
|
||||
executionId: string;
|
||||
nodeName: string;
|
||||
nodeId?: string;
|
||||
workflowId?: string;
|
||||
workflowName: string;
|
||||
nodeType?: string;
|
||||
|
||||
@@ -561,6 +561,8 @@ describe('LogStreamingEventRelay', () => {
|
||||
executionId: 'exec456',
|
||||
nodeName: 'HTTP Request',
|
||||
workflow,
|
||||
nodeId: 'node2',
|
||||
nodeType: 'n8n-nodes-base.httpRequest',
|
||||
};
|
||||
|
||||
eventService.emit('node-pre-execute', event);
|
||||
@@ -573,6 +575,7 @@ describe('LogStreamingEventRelay', () => {
|
||||
workflowId: 'wf303',
|
||||
workflowName: 'Test Workflow with Nodes',
|
||||
nodeType: 'n8n-nodes-base.httpRequest',
|
||||
nodeId: 'node2',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -606,6 +609,8 @@ describe('LogStreamingEventRelay', () => {
|
||||
executionId: 'exec789',
|
||||
nodeName: 'HTTP Response',
|
||||
workflow,
|
||||
nodeId: 'node2',
|
||||
nodeType: 'n8n-nodes-base.httpResponse',
|
||||
};
|
||||
|
||||
eventService.emit('node-post-execute', event);
|
||||
@@ -618,6 +623,7 @@ describe('LogStreamingEventRelay', () => {
|
||||
workflowId: 'wf404',
|
||||
workflowName: 'Test Workflow with Completed Node',
|
||||
nodeType: 'n8n-nodes-base.httpResponse',
|
||||
nodeId: 'node2',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,13 +111,17 @@ export type RelayEventMap = {
|
||||
'node-pre-execute': {
|
||||
executionId: string;
|
||||
workflow: IWorkflowBase;
|
||||
nodeId?: string;
|
||||
nodeName: string;
|
||||
nodeType?: string;
|
||||
};
|
||||
|
||||
'node-post-execute': {
|
||||
executionId: string;
|
||||
workflow: IWorkflowBase;
|
||||
nodeId?: string;
|
||||
nodeName: string;
|
||||
nodeType?: string;
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
@@ -180,28 +180,42 @@ export class LogStreamingEventRelay extends EventRelay {
|
||||
|
||||
// #region Node
|
||||
|
||||
private nodePreExecute({ workflow, executionId, nodeName }: RelayEventMap['node-pre-execute']) {
|
||||
private nodePreExecute({
|
||||
workflow,
|
||||
executionId,
|
||||
nodeId,
|
||||
nodeName,
|
||||
nodeType,
|
||||
}: RelayEventMap['node-pre-execute']) {
|
||||
void this.eventBus.sendNodeEvent({
|
||||
eventName: 'n8n.node.started',
|
||||
payload: {
|
||||
workflowId: workflow.id,
|
||||
workflowName: workflow.name,
|
||||
executionId,
|
||||
nodeType: workflow.nodes.find((n) => n.name === nodeName)?.type,
|
||||
nodeType,
|
||||
nodeName,
|
||||
nodeId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private nodePostExecute({ workflow, executionId, nodeName }: RelayEventMap['node-post-execute']) {
|
||||
private nodePostExecute({
|
||||
workflow,
|
||||
executionId,
|
||||
nodeType,
|
||||
nodeName,
|
||||
nodeId,
|
||||
}: RelayEventMap['node-post-execute']) {
|
||||
void this.eventBus.sendNodeEvent({
|
||||
eventName: 'n8n.node.finished',
|
||||
payload: {
|
||||
workflowId: workflow.id,
|
||||
workflowName: workflow.name,
|
||||
executionId,
|
||||
nodeType: workflow.nodes.find((n) => n.name === nodeName)?.type,
|
||||
nodeType,
|
||||
nodeName,
|
||||
nodeId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ describe('Execution Lifecycle Hooks', () => {
|
||||
const workflowExecutionService = mockInstance(WorkflowExecutionService);
|
||||
|
||||
const nodeName = 'Test Node';
|
||||
const nodeType = 'n8n-nodes-base.testNode';
|
||||
const nodeId = 'test-node-id';
|
||||
const node = mock<INode>();
|
||||
const workflowId = 'test-workflow-id';
|
||||
const executionId = 'test-execution-id';
|
||||
@@ -63,7 +65,16 @@ describe('Execution Lifecycle Hooks', () => {
|
||||
active: true,
|
||||
isArchived: false,
|
||||
connections: {},
|
||||
nodes: [],
|
||||
nodes: [
|
||||
{
|
||||
id: nodeId,
|
||||
name: nodeName,
|
||||
type: nodeType,
|
||||
typeVersion: 1,
|
||||
position: [100, 200],
|
||||
parameters: {},
|
||||
},
|
||||
],
|
||||
settings: {},
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
@@ -155,6 +166,8 @@ describe('Execution Lifecycle Hooks', () => {
|
||||
executionId,
|
||||
workflow: workflowData,
|
||||
nodeName,
|
||||
nodeType,
|
||||
nodeId,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -167,6 +180,8 @@ describe('Execution Lifecycle Hooks', () => {
|
||||
executionId,
|
||||
workflow: workflowData,
|
||||
nodeName,
|
||||
nodeType,
|
||||
nodeId,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,11 +52,27 @@ function hookFunctionsNodeEvents(hooks: ExecutionLifecycleHooks) {
|
||||
const eventService = Container.get(EventService);
|
||||
hooks.addHandler('nodeExecuteBefore', function (nodeName) {
|
||||
const { executionId, workflowData: workflow } = this;
|
||||
eventService.emit('node-pre-execute', { executionId, workflow, nodeName });
|
||||
const node = workflow.nodes.find((n) => n.name === nodeName);
|
||||
|
||||
eventService.emit('node-pre-execute', {
|
||||
executionId,
|
||||
workflow,
|
||||
nodeId: node?.id,
|
||||
nodeName,
|
||||
nodeType: node?.type,
|
||||
});
|
||||
});
|
||||
hooks.addHandler('nodeExecuteAfter', function (nodeName) {
|
||||
const { executionId, workflowData: workflow } = this;
|
||||
eventService.emit('node-post-execute', { executionId, workflow, nodeName });
|
||||
const node = workflow.nodes.find((n) => n.name === nodeName);
|
||||
|
||||
eventService.emit('node-post-execute', {
|
||||
executionId,
|
||||
workflow,
|
||||
nodeId: node?.id,
|
||||
nodeName,
|
||||
nodeType: node?.type,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ describe('ExecutionRecoveryService', () => {
|
||||
workflowName: workflow.name,
|
||||
nodeName: 'DebugHelper',
|
||||
nodeType: 'n8n-nodes-base.debugHelper',
|
||||
nodeId: '123',
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ export const setupMessages = (executionId: string, workflowName: string): EventM
|
||||
workflowName,
|
||||
nodeName: 'When clicking "Execute workflow"',
|
||||
nodeType: 'n8n-nodes-base.manualTrigger',
|
||||
nodeId: '123',
|
||||
},
|
||||
}),
|
||||
new EventMessageNode({
|
||||
@@ -24,6 +25,7 @@ export const setupMessages = (executionId: string, workflowName: string): EventM
|
||||
workflowName,
|
||||
nodeName: 'When clicking "Execute workflow"',
|
||||
nodeType: 'n8n-nodes-base.manualTrigger',
|
||||
nodeId: '123',
|
||||
},
|
||||
}),
|
||||
new EventMessageNode({
|
||||
@@ -33,6 +35,7 @@ export const setupMessages = (executionId: string, workflowName: string): EventM
|
||||
workflowName,
|
||||
nodeName: 'DebugHelper',
|
||||
nodeType: 'n8n-nodes-base.debugHelper',
|
||||
nodeId: '123',
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user