Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

n8n: Respond to a Webhook Instantly and Keep the Workflow Running

说明与用途

在 n8n 中,默认的 webhook 响应会等到整个工作流完成后才返回,导致超时。将响应模式设置为 "On Received" 或使用 "Respond to Webhook" 节点,可让客户端快速收到 200 响应,而工作流继续在后台执行。

问题

When a webhook triggers an n8n workflow, the HTTP response is delayed until the entire workflow finishes, causing client timeouts and poor UX.

结果

Clients receive a 200 response within 150 ms, while the workflow continues to run heavy tasks in the background, eliminating timeouts and improving user experience.

工作流

  • Configure webhook node to use "On Received" or "Using 'Respond to Webhook' Node'" response mode
  • If using "On Received", set response code 200 and optional message
  • If using "Respond to Webhook", add a Code node to generate a jobId and timestamp
  • Connect Code node output to a Respond to Webhook node with JSON body {success:true, jobId:…}
  • Continue workflow with heavy nodes (AI, PDF, DB, Slack) after the Respond node
  • Optional: attach an Error Workflow to notify on failures
  • Optional: write status to DB and expose polling endpoint for final result

证据

By default, n8n couples the lifecycle of an incoming HTTP request to the lifecycle of the entire workflow.

来源

Pattern B: Generate Ticket, Respond Early, Then Continue

来源

  • 记录日期: 2026-09-15T03:01:38.551Z