mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
🐛 Swallow telemetry error and only log in warn and debug mode (#2858)
* catch nodegraph errors * use loglevel config for telemetry * Use getByNameAndVersion instead of getByName * remove any usage of nodeTypes.getByName method * deprecate getByName method
This commit is contained in:
parent
2b9f3aab1b
commit
8fc1095d1e
|
@ -54,13 +54,6 @@ const mockNodeTypes: INodeTypes = {
|
|||
// @ts-ignore
|
||||
return Object.values(this.nodeTypes).map((data) => data.type);
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined {
|
||||
if (this.nodeTypes[nodeType] === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return this.nodeTypes[nodeType].type;
|
||||
},
|
||||
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined {
|
||||
if (this.nodeTypes[nodeType] === undefined) {
|
||||
return undefined;
|
||||
|
@ -524,7 +517,7 @@ export class CredentialsHelper extends ICredentialsHelper {
|
|||
nodeType = credentialTestFunction.nodeType;
|
||||
} else {
|
||||
const nodeTypes = NodeTypes();
|
||||
nodeType = nodeTypes.getByName('n8n-nodes-base.noOp') as INodeType;
|
||||
nodeType = nodeTypes.getByNameAndVersion('n8n-nodes-base.noOp');
|
||||
}
|
||||
|
||||
const node: INode = {
|
||||
|
|
|
@ -33,13 +33,6 @@ class NodeTypesClass implements INodeTypes {
|
|||
return Object.values(this.nodeTypes).map((data) => data.type);
|
||||
}
|
||||
|
||||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined {
|
||||
if (this.nodeTypes[nodeType] === undefined) {
|
||||
throw new Error(`The node-type "${nodeType}" is not known!`);
|
||||
}
|
||||
return this.nodeTypes[nodeType].type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variant of `getByNameAndVersion` that includes the node's source path, used to locate a node's translations.
|
||||
*/
|
||||
|
|
|
@ -58,6 +58,7 @@ export class Telemetry {
|
|||
this.versionCli = versionCli;
|
||||
|
||||
const enabled = config.get('diagnostics.enabled') as boolean;
|
||||
const logLevel = config.get('logs.level') as boolean;
|
||||
if (enabled) {
|
||||
const conf = config.get('diagnostics.config.backend') as string;
|
||||
const [key, url] = conf.split(';');
|
||||
|
@ -69,7 +70,7 @@ export class Telemetry {
|
|||
return;
|
||||
}
|
||||
|
||||
this.client = new TelemetryClient(key, url);
|
||||
this.client = new TelemetryClient(key, url, { logLevel });
|
||||
|
||||
this.pulseIntervalReference = setInterval(async () => {
|
||||
void this.pulse();
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
IRunExecutionData,
|
||||
IWorfklowIssues,
|
||||
IWorkflowDataProxyAdditionalKeys,
|
||||
TelemetryHelpers,
|
||||
Workflow,
|
||||
NodeHelpers,
|
||||
} from 'n8n-workflow';
|
||||
|
@ -224,17 +223,6 @@ export const workflowHelpers = mixins(
|
|||
// Does not get used in Workflow so no need to return it
|
||||
return [];
|
||||
},
|
||||
getByName: (nodeType: string): INodeType | INodeVersionedType | undefined => {
|
||||
const nodeTypeDescription = this.$store.getters.nodeType(nodeType) as INodeTypeDescription | null;
|
||||
|
||||
if (nodeTypeDescription === null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
description: nodeTypeDescription,
|
||||
};
|
||||
},
|
||||
getByNameAndVersion: (nodeType: string, version?: number): INodeType | undefined => {
|
||||
const nodeTypeDescription = this.$store.getters.nodeType(nodeType, version) as INodeTypeDescription | null;
|
||||
|
||||
|
|
|
@ -1193,7 +1193,6 @@ export interface INodeTypes {
|
|||
nodeTypes: INodeTypeData;
|
||||
init(nodeTypes?: INodeTypeData): Promise<void>;
|
||||
getAll(): Array<INodeType | INodeVersionedType>;
|
||||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined;
|
||||
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,10 @@ import {
|
|||
INodesGraphResult,
|
||||
IWorkflowBase,
|
||||
INodeTypes,
|
||||
INodeType,
|
||||
} from '.';
|
||||
|
||||
import { getInstance as getLoggerInstance } from './LoggerProxy';
|
||||
|
||||
export function getNodeTypeForName(workflow: IWorkflowBase, nodeName: string): INode | undefined {
|
||||
return workflow.nodes.find((node) => node.name === nodeName);
|
||||
}
|
||||
|
@ -26,6 +27,7 @@ export function generateNodesGraph(
|
|||
};
|
||||
const nodeNameAndIndex: INodeNameIndex = {};
|
||||
|
||||
try {
|
||||
workflow.nodes.forEach((node: INode, index: number) => {
|
||||
nodesGraph.node_types.push(node.type);
|
||||
const nodeItem: INodeGraphItem = {
|
||||
|
@ -40,8 +42,9 @@ export function generateNodesGraph(
|
|||
nodeItem.domain = node.parameters.url as string;
|
||||
}
|
||||
} else {
|
||||
const nodeType = nodeTypes.getByName(node.type) as INodeType;
|
||||
nodeType.description.properties.forEach((property) => {
|
||||
const nodeType = nodeTypes.getByNameAndVersion(node.type);
|
||||
|
||||
nodeType?.description.properties.forEach((property) => {
|
||||
if (
|
||||
property.name === 'operation' ||
|
||||
property.name === 'resource' ||
|
||||
|
@ -71,6 +74,12 @@ export function generateNodesGraph(
|
|||
});
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
const logger = getLoggerInstance();
|
||||
logger.warn(`Failed to generate nodes graph for workflowId: ${workflow.id as string | number}`);
|
||||
logger.warn((e as Error).message);
|
||||
logger.warn((e as Error).stack ?? '');
|
||||
}
|
||||
|
||||
return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex };
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
INodeType,
|
||||
INodeTypeData,
|
||||
INodeTypes,
|
||||
INodeVersionedType,
|
||||
IRunExecutionData,
|
||||
ITaskDataConnections,
|
||||
IWorkflowBase,
|
||||
|
@ -614,7 +615,7 @@ class NodeTypesClass implements INodeTypes {
|
|||
return Object.values(this.nodeTypes).map((data) => NodeHelpers.getVersionedNodeType(data.type));
|
||||
}
|
||||
|
||||
getByName(nodeType: string): INodeType {
|
||||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined {
|
||||
return this.getByNameAndVersion(nodeType);
|
||||
}
|
||||
|
||||
|
|
|
@ -618,7 +618,7 @@ describe('RoutingNode', () => {
|
|||
const runExecutionData: IRunExecutionData = { resultData: { runData: {} } };
|
||||
const additionalData = Helpers.WorkflowExecuteAdditionalData();
|
||||
const path = '';
|
||||
const nodeType = nodeTypes.getByName(node.type);
|
||||
const nodeType = nodeTypes.getByNameAndVersion(node.type);
|
||||
|
||||
const workflowData = {
|
||||
nodes: [node],
|
||||
|
@ -1596,7 +1596,7 @@ describe('RoutingNode', () => {
|
|||
const connectionInputData: INodeExecutionData[] = [];
|
||||
const runExecutionData: IRunExecutionData = { resultData: { runData: {} } };
|
||||
const additionalData = Helpers.WorkflowExecuteAdditionalData();
|
||||
const nodeType = nodeTypes.getByName(baseNode.type);
|
||||
const nodeType = nodeTypes.getByNameAndVersion(baseNode.type);
|
||||
|
||||
const inputData: ITaskDataConnections = {
|
||||
main: [
|
||||
|
|
Loading…
Reference in a new issue