跳到正文
Skillpedia
自动化23k · #10128

n8n-error-handling

它能做什么

这项技能说明如何在 n8n 工作流中捕获错误、返回清晰的状态码、对网络步骤进行重试,并在出现故障时通知相关人员。适合运行无人值守的 n8n 自动化或 webhook 的人。

适用场景

  • ✓当你正在构建其他系统所依赖的 n8n webhook 或 API 时。
  • ✓当定时运行的 n8n 工作流失败,而无人察觉时。
  • ✓当你希望 n8n 在临时网络问题导致某步骤失败时进行重试时。

技能链接

https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-error-handling/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-error-handling/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请让我的 n8n webhook 返回清晰的错误代码,并在某个步骤失败时通知我。”

每周 5 个新技能,1 分钟读完。

工作原理

技能会把每个步骤的失败送入其各自的错误分支,根据原因设置响应状态,并为穿过这些分支的错误添加工作流级别的错误处理程序。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

n8n Error Handling

By default, when an n8n node throws, the whole workflow halts. For an interactive run you're watching, that's fine — you see the red node and fix it. For anything unattended (a webhook API, a cron job, a queue worker, an agent tool), it's the wrong default: the caller gets a timeout or an empty 500, the operator gets no alert, and the symptom is "the integration just stopped working" with no log and no clue.

This skill is about making failures loud, structured, and recoverable — and, best case, self-healing so transient blips never reach a human at all.

The two ideas that prevent most silent failures:

  • Per-node error outputs — a node's failure routes down a second output you control, instead of killing the run.
  • A workflow-level error workflow — a catch-all that fires for anything that escapes per-node handling (timeouts, crashes between nodes, unwired failures).

When you actually need this

Workflow shape Error handling posture
Webhook / API (anything with Respond to Webhook) Required. Every fallible node's error output wired; status code matches cause.
Scheduled / cron / queue worker / agent tool (unattended) Required. A workflow-level error workflow, plus retryOnFail on network nodes.
Internal one-off you run and watch yourself Optional. Default onError: "stopWorkflow" is fine — you'll see the red node and re-run.

The dividing line: if anyone other than you sees the output — a downstream system, an end user, an on-call engineer — the failure has to be handled, not swallowed. If you're the only watcher and the cost of failure is "I notice and re-run", looser is fine.


The #1 silent trap: per-node error output is a TWO-step setup

This is the single most common way an n8n workflow "handles" errors while actually swallowing them. Routing a node's failure to a handler takes two changes, and doing only one looks complete but misbehaves:

  1. Set onError: "continueErrorOutput" on the node. This is what creates the second output. Without it, main[1] doesn't exist no matter what you wire.
  2. Wire that error output (connections.<node>.main[1], i.e. sourceIndex: 1) to a real handler. Without a target, the error data is emitted into the void.

Get one without the other and you hit a failure mode:

What you did What happens at runtime
onError set, error output not wired Error data is silently discarded. Downstream doesn't fire. The dashboard shows the run as succeeded. Worst case — no error logged anywhere.
Error output wired, onError not set The slot never fires; the handler is unreachable. On failure the workflow just halts (default stopWorkflow).
Both done Failure routes down main[1] to your handler. ✅

Doing both with n8n_update_partial_workflow

// 1) Turn on the error output (creates main[1])
{ type: "updateNode", nodeName: "HTTP Request",
  changes: { onError: "continueErrorOutput" } }

// 2) Wire the error output to a handler. sourceIndex: 1 = the error output.
{ type: "addConnection",
  source: "HTTP Request",
  target: "Handle Error",
  sourceIndex: 1 }

sourceIndex: 0 is the success path, sourceIndex: 1 is the error path. (For IF nodes the aliases branch: "true"/"false" map to index 0/1; for a generic fallible node, use the explicit sourceIndex: 1.)

Then verify. This trap doesn't surface in validate_workflow — a half-wired error output validates clean. Pull the workflow with n8n_get_workflow and confirm both halves:

  • The node's onError is "continueErrorOutput".
  • connections["HTTP Request"].main[1] contains your handler.

Valid onError values:

Value Effect
"stopWorkflow" (default) Error halts the whole workflow.
"continueRegularOutput" Error item flows out the normal output. Rare, usually wrong — downstream gets error-shaped data and keeps going.
"continueErrorOutput" Error item flows out the separate error output (main[1]). The one you wire.

Full failure-mode catalog, fan-in/fan-out shapes, and verification: NODE_ERROR_OUTPUTS.md.


Self-healing first: retryOnFail before you wire error paths

Before you build error branches, absorb the transient failures so they never reach those branches. On any node that calls a network service — HTTP Request, comms (Gmail/Slack/Discord), databases, AI nodes,

常见问题

为什么一个错误会让整个工作流停止?

默认情况下,n8n 在某个步骤失败时会暂停工作流。这适合你亲自盯着的运行,但对无人值守的运行有风险。

什么是重试设置?

它会让 n8n 重新尝试失败的步骤,技能建议对网络步骤使用。

我需要单独的错误工作流吗?

对于无人值守或定时的工作流,技能建议使用工作流级别的错误工作流作为兜底。

详情

作者的原始描述

Wire n8n error handling so failures are loud, structured, and recoverable. Use when building any webhook/API workflow, a scheduled or unattended workflow, or any path where a silent failure would drop user-visible work — and whenever the user mentions error handling, onError, continueErrorOutput, error branches/outputs, retries, retryOnFail, Respond to Webhook status codes, 4xx/5xx, Error Trigger, or "my workflow fails silently". Covers per-node error outputs and wiring, retry/self-healing, error-trigger workflows, and 4xx/5xx response shapes.

repo: czlonkowski/n8n-mcp

热度

GitHub 星标
23k
排名
#10128
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能