n8n-error-handling
Skill này làm gì
Skill này giải thích cách bắt lỗi trong quy trình n8n, trả về mã trạng thái rõ ràng, thử lại các bước mạng và cảnh báo ai đó khi có sự cố. Skill dành cho người vận hành tự động hóa n8n không cần giám sát hoặc webhook.
Khi nào nên dùng
- ✓Khi bạn đang xây dựng một webhook hoặc API n8n mà các hệ thống khác phụ thuộc vào.
- ✓Khi một quy trình n8n theo lịch bị lỗi mà không ai nhận ra.
- ✓Khi bạn muốn n8n thử lại một bước bị lỗi do sự cố mạng tạm thời.
Liên kết skill
https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-error-handling/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm cho webhook n8n của tôi trả về mã lỗi rõ ràng và cảnh báo tôi khi một bước bị lỗi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill đưa lỗi của mỗi bước vào nhánh lỗi riêng, đặt trạng thái phản hồi phù hợp với nguyên nhân, và thêm trình xử lý lỗi ở cấp quy trình cho những lỗi vượt qua các nhánh đó.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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:
- 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. - 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
onErroris"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,
Câu hỏi thường gặp
Vì sao cả quy trình dừng lại sau một lỗi?
Mặc định n8n dừng quy trình khi một bước lỗi, điều này phù hợp với các lần chạy bạn theo dõi nhưng rủi ro với quy trình không giám sát.
Cài đặt thử lại là gì?
Đó là cách làm n8n thử lại một bước bị lỗi, và skill gợi ý dùng cho các bước mạng.
Tôi có cần quy trình xử lý lỗi riêng không?
Với quy trình không giám sát hoặc theo lịch, skill khuyên dùng một quy trình xử lý lỗi ở cấp quy trình như lớp bắt tổng quát.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 23k
- Vị trí xếp hạng
- #10128
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
n8n-agents
23kDạy agent của bạn thiết kế agent AI trong n8n cho tốt, với mô hình, công cụ, bộ nhớ và định dạng đầu ra phù hợp.
n8n-binary-and-data
23kDạy agent của bạn xử lý các tệp như PDF và hình ảnh trong quy trình n8n mà không làm mất chúng giữa chừng.
n8n-code-tool
23kDạy agent của bạn viết JavaScript hoặc Python cho Custom Code Tool của n8n, để agent AI có thể gọi nó như một công cụ.
n8n-multi-instance
23kGiúp agent của bạn làm việc an toàn trên nhiều instance n8n, như production và staging, mà không thay đổi nhầm instance.
Skill tương tự
knowledge-automation
394kGiúp agent của bạn thiết lập tác vụ định kỳ đưa nội dung mới vào kho Knowledge theo lịch, rồi kiểm tra tác vụ có chạy không.
knowledge-source-ingest
394kGiúp agent của bạn cập nhật Knowledge vault với các mục mới từ kênh chat, nguồn tin hoặc hộp thư, mà không thêm lại những gì đã có.
benchmark
280kGiúp agent của bạn đo tốc độ và hiệu suất của code, hữu ích để đảm bảo mọi thứ nhanh và tìm ra những chỗ chậm.