匠人学院 JR Academy
  • Position

    Where am I now, and where should I go?

    How your job is changing, where your experience can take you and what you still need for a target role, worked out from what you have actually done. Free, and the full result needs no sign-up.

    Analyse my career and skills

    Look up a career

    Will AI replace my job?AI impact and transition paths for common careersNew jobs in the AI eraWhat they do, what they need, how to move in

    Focused tools

    AI Engineer interview readiness30 timed questions on what you still need before interviewsCareer personality testDirections that suit how you workReturning to China checkJob prospects in China by school, major and graduation date

    AI coach

    Talk to your AI coachStill unsure after your result? Talk through what is holding you back
  • Core courses

    AI Engineer BootcampEngineering bootcamp from LLM apps to agentsAI Engineer Full-Stack Project Class16 weeks · RAG and full-stack AI projectsVibe Coding Masterclass8 weeks · direct agents to build and ship a productAI Essentials10 hours · use AI for email, reports, data and copyAI Office Automation Course8 weeks · help a whole company adopt AIOne-Person Company (OPC) Bootcamp15 weeks in person · build a one-person company with AIAll courses →

    AI engineering

    Machine Learning & Data Engineering Full-Stack ClassAI Agent & MCP Project BootcampAI Engineer Core TechniquesAI Engineer FoundationsAI Engineer Advanced: RAG to Agents and TuningClaude Code TasterAll AI engineering courses →

    AI at work

    AI Coding for everyoneClaude Code One-Day Masterclass (Non-Technical)Enterprise AI Automation BootcampAI Marketing BootcampAI Risk, Governance and Audit CourseOpenClaw 4-Week Personal AI Assistant BootcampAll AI-at-work courses →

    Career development

    AI Product Manager (BA) Bootcamp + InternshipAustralia IT Interview BootcampAustralia IT Technical Interview BootcampAustralia IT Resume BootcampAustralia Big Tech Job Search BootcampAustralia IT Career Planning BootcampAll career courses →

    Learn free first

    Vibe CodingAI for office workPrompt MasterAI EngineerAI data analysisResource centerInstructorsAll learning paths →
  • Evidence

    What will convince an employer?

    Certifications, projects, team work and competition entries, collected into one portfolio.

    See the portfolio

    Certifications

    Cert Master · all certificationsPrep and mock exams for AWS, Azure, GCP, Claude and moreAWS CLF-C02Entry-level AWS cloud certificationAWS SAA-C03Entry certification for cloud architectsClaude certificationsAnthropic Claude certification seriesAll certifications →

    Projects and team work

    P3 team projectsBuild a project with real teammates in a simulated team workflowP3 project experienceThe parts of a P3 project that go on your resumeDemo DayProject showcaseP3 certificatesProof once a project is completeAll of P3 →

    Competitions and work

    HackathonsBuild something against the clockSubmit your workAdd your project to the showcaseCareerOS portfolioDo tasks in the desktop app; your results become portfolio pieces
    Cert MasterBrowser extension, app and mini programScreenshot a question for analysis and practise anywhereAbout Cert Master
  • Connect

    How do I get myself in front of employers?

    Resume, interviews, referrals and mentors. See how far you are from the target role first, then decide what to fix.

    Start with Jobpin

    Resume and openings

    Graduate careersGraduate preparation across Australia, China, Malaysia, Singapore, the US and UKJobpinAI job search workspace: resume, roles, applicationsAI resumeRewrite your resume against a job descriptionReferralsRoles shared by students and mentorsOpportunitiesInternships, projects and collaborationsOffer boardOffers students have received

    Interviews

    AI Engineer interview guideSeven areas, with worked examplesFDE interview guideFive rounds, from scoping to the customer roundAI mock interviewPractise by text or voice and see the gapsInterview storiesReal interview experiencesSystem Design handbookPrepare for system design interviewsAll interview prep →

    Mentors

    1:1 mentorsBook AI, career and technical mentors by the hourGroup tutoringShare a tutor with a few others and pay less eachCareer coachingResume, interview and direction packages
    Jobpin desktopOne workspace for the whole job searchOrganise real experience and refine resume versions for target roles on macOS or Windows.About Jobpin
BusinessMembershipDownload CareerOS
0
匠人学院 JR Academy

Follow Us

linkedinfacebooktwitterinstagramyoutube

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png
Airbotix · AI learning & creation for kids Another Life · AI story game
Products46

CareerOS and tools

  • CareerOS
  • Cert Master
  • Jobpin
  • Jobpin web
  • Jobpin report
  • Jobpin desktop download
  • My job search reports
  • Buy report credits
  • Jobpin billing
  • AI Toolbox
  • AI Skill Marketplace

Membership

  • Membership
  • AI membership

Courses

  • Bootcamps
  • Training Camp
  • Kanban learning
  • AI Builder course
  • MCP course
  • NotebookLM workshop
  • Business Analyst course
  • Web Full-Stack Bootcamp
  • DevOps Bootcamp
  • Data Engineering Bootcamp
  • Data Analysis Bootcamp
  • Coding for Beginners
  • Algorithm Bootcamp

Career services

  • Graduate careers
  • Graduate careers in Australia
  • Graduate careers in China
  • Graduate careers in Malaysia
  • Graduate careers in Singapore
  • Graduate careers in the US
  • Graduate careers in the UK
  • 1:1 coaching
  • Career coaching
  • AI Engineer VIP
  • BA & PM Internship
  • Data Science Internship
  • Data Analysis Internship
  • Marketing Internship
  • Resume Review
  • Interview Coaching
  • Job Application Service
  • Job Monitoring
  • LinkedIn Management
  • LinkedIn Networking
Library57

Learning paths

  • All Learning Paths
  • AI Engineer
  • Context Engineering
  • Vibe Coding
  • Prompt Master
  • AI Builder
  • AI Product Manager
  • Python Basics
  • AI Productivity
  • AI Data Analysis
  • AI Finance
  • AI Content Creation
  • AI Image Creation
  • Frontend Development
  • Hermes Agent
  • OpenClaw Local Agent

Interactive labs

  • Prompt Lab
  • Frontend Lab
  • JavaScript Lab
  • Python Lab
  • AWS Lab
  • Azure Lab
  • LLM Lab
  • Git Lab

Reference and guides

  • Resources
  • Wiki
  • Cheat sheets
  • Roadmaps
  • AI roadmaps
  • Videos
  • Ebooks
  • Blog
  • Interview handbook
  • Mock exams
  • Free resources

Cities

  • Sydney
  • Melbourne
  • Brisbane
  • Adelaide
  • Singapore
  • Kuala Lumpur
  • London
  • New York
  • San Francisco
  • Los Angeles
  • Seattle
  • Toronto
  • Vancouver

Immigration

  • Australia Immigration
  • Skilled Visa 189/190/491
  • Employer Sponsored 482/186/494
  • Business Visa 188/888
  • UK Immigration
  • US Immigration
  • Canada Immigration
  • Singapore immigration
  • Malaysia immigration
Business20

For business

  • AI for Business
  • Business portal sign-in
  • Corporate Training
  • Internship Partnership
  • Recruitment Partnership
  • Enterprise (EN)

Metatree AI Lab

  • Metatree AI Lab (Chinese)
  • AI solutions (Chinese)
  • Digital employees (Chinese)
  • Case studies (Chinese)
  • Metatree AI Lab
  • AI services
  • Digital employees
  • Case studies

AI education for kids

  • Airbotix — AI Learning & Creation for Kids
  • AU Family Resource Hub
  • NAPLAN Report Guide
  • My School Data Guide
  • Sydney Private School Fees 2026
  • Kids Coding Programs
About15

Company

  • About Us
  • Our Mentors
  • Become a Mentor
  • Metaverse Classroom
  • JR Careers
  • Another Life — AI Story Game
  • Contact Us

Help and policies

  • FAQs
  • Terms & Conditions
  • Privacy Policy
  • Cancellation & Refund Policy
  • Site map

Friend links

  • CS Browser

Contact

  • hello@jiangren.com.au
  • 0421-672-555

Offices

Level 10b, 144 Edward Street, Brisbane CBD (Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
45A13, Block B, Oriental Hope Tianxiang Plaza, 500 Tianfu Avenue Middle Section, Wuhou District, Chengdu, Sichuan, China
Business Hub, 155 Waymouth St, Adelaide SA 5000
Disclaimer
footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

All content on the JR Academy website, including course materials, logos, and information provided, is protected under Australian intellectual property laws. Unauthorized use, sale, distribution, reproduction, or modification is strictly prohibited. Violations may result in legal action. By accessing our website, you agree to respect our intellectual property. JR Academy Pty Ltd reserves all rights, including patents, trademarks, and copyrights. Any infringement will be subject to legal prosecution. View Terms of Service

© 2017-2026 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572

HomeLearnCoursesCerts
  1. Home
  2. Learn
  3. Blog
  4. n8n 自动化工作流实战指南 — n8n 错误处理与生产监控:工作流永不静默失败
JR Academy · BlogCareer insights

n8n 自动化工作流实战指南 — n8n 错误处理与生产监控:工作流永不静默失败

Error Workflow 标准配置、节点级错误控制、重试与指数退避、Slack 告警模板、集中式监控——让你的生产工作流在出错时发声而不是消失

Published2026-11-30
Reading time3 min
Author

Contents

  • 核心工具:Error Workflow + Error Trigger
  • 第一步:建立集中式 Error Workflow
  • Error Trigger 节点
  • Code 节点:格式化告警内容
  • Slack 节点
  • 第二步:给每个生产工作流挂上 Error Workflow
  • 第三步:节点级错误控制
  • Continue on Error
  • Retry on Fail
  • 进阶:指数退避重试
  • 常见错误模式与处理策略
  • 集中式错误日志
  • 生产监控建议
  • 执行历史清理策略
  • 关键工作流的"心跳"监控
  • 慢工作流告警
  • 检查清单:工作流上线前必过

生产环境里工作流失败是必然的——API 会超时、Webhook 会送错 payload、AI 偶尔会返回无法解析的格式。问题不在于"失败发生了",而在于你是发现了它,还是它悄悄消失了。

n8n 默认行为:工作流失败 → 执行状态标红 → 没有任何通知。如果没人每天盯着执行历史看,你可能三天后才知道自动日报已经停了。

这章把正确的错误处理姿势从头到尾说清楚。


核心工具:Error Workflow + Error Trigger

n8n 的错误处理分两层:

  1. 节点级:单个节点失败时怎么办(继续 / 停止 / 重试)
  2. 工作流级:整个工作流失败时触发另一个专门的 Error Workflow 发告警

大多数人只配了节点级,漏掉了工作流级——这是最容易静默失败的根源。


第一步:建立集中式 Error Workflow

创建一个专门处理错误通知的工作流(不要把错误处理塞到每个业务工作流里):

Error Trigger
    ↓
Code(格式化错误信息)
    ↓
Slack(发告警 + 直接跳转链接)
    ↓
Google Sheets(记录错误日志,留历史记录)

Error Trigger 节点

新建工作流,第一个节点选 "Error Trigger"。这个节点不需要任何配置——它在关联的工作流失败时自动触发,并把错误信息注入 $json。

Error Trigger 提供的数据结构:

// $json 的内容
{
  "execution": {
    "id": "1234",                          // 直接跳到失败执行的 ID
    "url": "https://你的n8n/workflow/5/executions/1234",
    "retryOf": null,
    "error": {
      "message": "Request failed with status 429",
      "stack": "Error: Request failed..."
    },
    "lastNodeExecuted": "HTTP Request"    // 哪个节点挂了
  },
  "workflow": {
    "id": "5",
    "name": "每日 AI 日报"
  }
}

Code 节点:格式化告警内容

const executionId = $json.execution.id;
const workflowName = $json.workflow.name;
const errorMessage = $json.execution.error.message;
const lastNode = $json.execution.lastNodeExecuted;
const executionUrl = $json.execution.url;

const now = new Date().toLocaleString('zh-CN', { timeZone: 'Australia/Sydney' });

return [{
  json: {
    title: `🔴 工作流失败:${workflowName}`,
    body: [
      `*时间*:${now}`,
      `*工作流*:${workflowName}`,
      `*失败节点*:${lastNode}`,
      `*错误信息*:${errorMessage}`,
      `*执行 ID*:${executionId}`,
      `*查看详情*:${executionUrl}`
    ].join('\n'),
    executionUrl
  }
}];

Slack 节点

Resource: Message
Operation: Post
Channel: #n8n-alerts
Text: {{ $json.body }}
Unfurl Links: false

收到的 Slack 消息带直达链接,点击就跳到失败执行的详情页,不用翻执行历史找。


第二步:给每个生产工作流挂上 Error Workflow

建好集中 Error Workflow 后,需要在每个生产工作流里指定它:

  1. 打开需要监控的工作流
  2. 点右上角的 ⚙️ Settings(工作流设置)
  3. 找到 Error Workflow 下拉框
  4. 选择你刚建的集中 Error Workflow
  5. 保存

这一步最容易被忘掉。建议养成习惯:每个新工作流上线前,把 Error Workflow 挂上是发布检查清单的最后一条。


第三步:节点级错误控制

每个节点右键 → Settings,可以配置该节点失败时的行为:

Continue on Error

用途:非关键步骤失败也不影响后续节点
典型场景:
  - 发通知(通知发失败,主流程不应中断)
  - 数据记录(写日志失败,不影响核心业务)
  - 可选的数据富化(API 调用返回空,继续用默认值)

Retry on Fail

Max Tries: 3(重试次数)
Wait Between Tries: 5000(毫秒,推荐至少 3000)

用途:网络抖动、API 限频等临时故障
典型场景:
  - HTTP Request 调外部 API
  - AI 模型调用(偶发超时)
  - Webhook 发送(网络不稳定)

注意:Retry on Fail 的等待是固定间隔,不是指数退避。对于严格限频的 API,固定间隔可能一直在触发限额,见下面的手动实现。


进阶:指数退避重试

当 API 返回 429(Too Many Requests)时,固定间隔重试会持续触发限额。正确做法是指数退避:第 1 次等 2s,第 2 次等 4s,第 3 次等 8s……

用 Code 节点手动实现:

// 放在 HTTP Request 节点后,捕获 429 并等待重试
const response = $("HTTP Request").item.json;

// 如果成功,直接透传
if (!$("HTTP Request").item.error) {
  return $input.item;
}

const attempt = $json.__attempt || 1;
const maxAttempts = 4;

if (attempt > maxAttempts) {
  throw new Error(`API 调用失败,已重试 ${maxAttempts} 次:${$json.error}`);
}

// 指数退避等待
const waitMs = Math.pow(2, attempt) * 1000; // 2s, 4s, 8s, 16s
await new Promise(resolve => setTimeout(resolve, waitMs));

return [{
  json: {
    ...$json,
    __attempt: attempt + 1
  }
}];

配合 n8n 的 "Loop Over Items" 节点,可以把这段逻辑做成真正的重试循环。


常见错误模式与处理策略

错误类型 典型表现 推荐处理
网络超时 ECONNRESET / socket hang up Retry on Fail(3 次,间隔 5s)
API 限频 429 Too Many Requests 指数退避重试 + 减少并发
认证失效 401 Unauthorized 停止工作流 + 立即告警(手动续期凭证)
数据格式错误 JSON.parse failed Continue + 记录原始 payload 到 Sheets 方便排查
AI 返回格式错误 解析 JSON 失败 重试 1 次 + 告警(AI 偶发格式问题)
下游服务 500 Internal Server Error 等 30s 重试,3 次后告警

集中式错误日志

告警容易漏(Slack 消息太多被划走)。在 Error Workflow 里同时写一份持久日志:

Google Sheets 节点(接在 Slack 节点后):

Operation: Append or Update Row
Spreadsheet: n8n 错误日志(运营同学可直接查看)
Sheet: Sheet1
Columns:
  timestamp:    {{ new Date().toISOString() }}
  workflow:     {{ $("Code").item.json.title }}
  error:        {{ $json.execution.error.message }}
  last_node:    {{ $json.execution.lastNodeExecuted }}
  execution_id: {{ $json.execution.id }}
  execution_url: {{ $json.execution.url }}

这样就有了可以按时间过滤的错误历史。发现某个工作流一周报错了 20 次,说明该接口需要专项排查,而不是每次人肉重跑。


生产监控建议

执行历史清理策略

执行日志会持续增长占磁盘,但删太激进又不方便排查:

# .env 里设置
EXECUTIONS_DATA_PRUNE=true
EXECUTIONS_DATA_MAX_AGE=336    # 14天(小时数 = 14*24)
EXECUTIONS_DATA_PRUNE_MAX_COUNT=10000  # 每个工作流最多保留1万条

失败的执行记录会被单独标记,可以在 Settings 里单独设置保留时间更长。

关键工作流的"心跳"监控

对于定时工作流(每天发日报、每周更新数据),光有错误告警不够——如果工作流直接没触发,就不会有错误,你也不会知道。

心跳模式:在工作流最后加一个 HTTP Request,每次成功执行时 ping 一个外部监控服务(如 healthchecks.io 免费版):

最后一个业务节点
    ↓
HTTP Request(心跳)
  Method: GET
  URL: https://hc-ping.com/你的检查ID

healthchecks.io 如果超过预定时间(如 26 小时)没收到 ping,就会发邮件告警。即使 n8n 整个挂了,心跳超时也能发现。

慢工作流告警

在工作流开始节点记录时间戳,结束时比较:

// 开始节点(Code)
return [{ json: { startTime: Date.now() } }];

// 结束节点(Code)
const duration = Date.now() - $("Start").item.json.startTime;
const durationMin = (duration / 60000).toFixed(1);

if (duration > 5 * 60 * 1000) {  // 超过5分钟告警
  // 触发 Slack 告警节点
  return [{ json: { slow: true, durationMin, threshold: 5 } }];
}
return [{ json: { slow: false, durationMin } }];

检查清单:工作流上线前必过

□ 设置了 Error Workflow(Workflow Settings → Error Workflow)
□ 关键 HTTP 节点开了 Retry on Fail(3次,5000ms间隔)
□ 不可逆操作(发邮件/改数据)加了 Human Approval 或 Continue on Error 配合日志
□ 生产 URL / Credential 都已切换(不是用的测试 key)
□ 执行历史清理已配置(防磁盘撑满)
□ 如果是定时工作流:心跳监控已配置

漏掉任何一条,在生产环境出问题只是时间问题。

Author
Share or copy the link
← Previous articlen8n 自动化工作流实战指南 — n8n MCP 实战:让 Claude / Cursor 直接调用你的工作流Next article →n8n 自动化工作流实战指南 — n8n 高阶技巧:Sub-workflow 模块化、Error Workflow 兜底与 Credentials 治理

Related articles

🇦🇺测一下:袋鼠国码农能当FDE吗?

2026-12-01

Monash 研究:肠道酸度是膳食纤维降血压的关键;AI 搬运新闻冲击维州选举信息;MPAC 公布 2027 演出季

2026-12-01

Adelaide 物理学家获 $250,000 总理科学奖;全球葡萄酒消费六十年降四分之一;残障师范生实习障碍研究

2026-12-01

DVA-C03今日上线首发 · Google Cloud AI Agent认证完整解析 · AZ-401本月GA替代AZ-400

2026-12-01

Anthropic推迟下一代模型并调百人做安全,AWS推出AI办公三件套,Google让用户单独关掉AI训练

2026-12-01

GitHub Copilot 实战指南 — Copilot AI Code Review:30 秒让 AI 帮你审 PR,三档深度随需切换

2026-11-30
View all articles →

Done reading? Next steps

Not sure what to learn next? Tell us where you are

Tell us what you do now and where you want to go. See your gaps in skills, evidence, experience, expression and positioning, and what to work on first. No sign-in needed.

Compare with my situation
  • SkillAI Engineer Bootcamp13 weeks, 12 Theory + 13 Practice live classes. You build one Agent system across Context, RAG, Tools, Memory and production Evals. Built for Applied AI and Agent Engineer roles.See the program →
  • PositioningLearning roadmaps by roleFrontend, backend, data, AI and more, laid out stage by stage in the order to learn them.All roadmaps →
  • ExpressionTry an AI mock interviewPick a role and run a mock interview to practise explaining your experience and projects.Practise now →

Not sure what to do next?

Take this page's topic with you and see where your gaps are.

Compare with my situation
JR Academy
AI learning for the global Chinese community
BootcampsFree resourcesLearn AICareer coaching
精选推荐
AI Career Impact Map
Assess career exposure and explore transition paths and learning options
Popular tool
AI & Data Bootcamps
Build your skills through structured courses and hands-on projects
Popular courses
1:1 Career Coaching
Work with an experienced mentor on your resume and interview preparation
Career coaching
Custom Corporate Training
AI training tailored to your team
Business services
Popular tags
Vibe CodingAI codingCursorClaudeJob searchPromptFrontend developmentBackend development
Subscribe to updates

Receive AI learning resources, technical tutorials and career advice by email.

We respect your privacy and do not send spam.