{"record":{"id":"67fca22355d67413","repo":"n8n-io/n8n","slug":"execution-was-cancelled","errorCode":null,"errorMessage":"Execution was cancelled","messagePattern":"Execution was cancelled","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/mcp/shared/runtime.ts","lineNumber":293,"sourceCode":" * and forward the call to the MCP server.\n *\n * When `enableSessionCache` is set, the connected client is kept alive in\n * {@link McpClientsManager} and reused across tool calls within the same execution,\n * so stateful MCP servers keep their session between Agent V3 tool calls. Otherwise\n * a fresh connection is opened and closed per call (legacy behaviour).\n */\nexport async function executeMcpTool(\n\tctx: IExecuteFunctions,\n\tresolveConfig: (itemIndex: number) => ResolvedMcpConfig | Promise<ResolvedMcpConfig>,\n\toptions: { enableSessionCache?: boolean } = {},\n): Promise<INodeExecutionData[][]> {\n\tconst node = ctx.getNode();\n\tconst items = ctx.getInputData();\n\tconst returnData: INodeExecutionData[] = [];\n\n\tconst assertNotCancelled = (itemIndex: number): void => {\n\t\tif (ctx.getExecutionCancelSignal()?.aborted) {\n\t\t\tthrow new NodeOperationError(node, 'Execution was cancelled', { itemIndex });\n\t\t}\n\t};\n\n\t// Require a real execution id: without one the cache key would collide across\n\t// concurrent executions (e.g. `undefined:NodeName`) and leak a session between\n\t// them. Fall back to the per-call connection in that case.\n\tconst executionId = ctx.getExecutionId();\n\n\tif (options.enableSessionCache && executionId) {\n\t\tassertNotCancelled(0);\n\n\t\tconst manager = Container.get(McpClientsManager);\n\t\tconst cacheKey = `${executionId}:${node.name}`;\n\t\t// One cached client per execution+node, connected with the first item's\n\t\t// config. Agent tool dispatch always sends a single item, so per-item\n\t\t// connection config does not apply here (only per-item `timeout` below).\n\t\tconst firstConfig = await resolveConfig(0);\n","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/mcp/shared/runtime.ts#L275-L311","documentation":"Error \"Execution was cancelled\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/nodes-langchain/nodes/mcp/shared/runtime.ts:293 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}