Skip to content

Exercise 1

Flaky API:   Webhook (GET flaky) → Respond to Webhook (Options → Response Code: {{ Math.random() < 0.67 ? 500 : 200 }})
Caller:      Manual Trigger → HTTP Request (GET http://localhost:5678/webhook/flaky)

Tested on n8n 2.43.6: the flaky endpoint returned 200 on 8 of 30 calls.

HTTP Request → Settings:

  • Retry On Fail: on
  • Max Tries: 5 (the maximum the setting allows)
  • Wait Between Tries (ms): 1000

With a 1/3 success chance per try, 5 tries succeed ~87% of the time. For more reliability, use the node's error output to loop back once more, or make the endpoint less flaky. Retries are for transient failures (timeouts, 5xx, rate limits). Don't retry a 400; it will fail every time.

Exercise 2

Gmail example, replacing the No Operation node:

  • To: your address
  • Subject: n8n error: {{ $json.workflow }}
  • Message: {{ $json.alert }}

Publish the Error Logger again after changing it. Slack: Send Message to a channel with text {{ $json.alert }}.

Exercise 3

Webhook (POST average) → Edit Fields → Execute Workflow (Divide) ─success→ Respond 200
                                                                 └error──→ Respond 422

Edit Fields:

  • sum (Number) = {{ ($json.body.numbers ?? []).reduce((s, n) => s + Number(n), 0) }}
  • count (Number) = {{ ($json.body.numbers ?? []).length }}

Execute Workflow maps a = {{ $json.sum }}, b = {{ $json.count }}, with On Error → Continue (using error output). An empty list gives count = 0, and the sub-workflow's division-by-zero error becomes your 422, with no new error handling needed. That's the payoff of reusable sub-workflows.

Stretch

In each workflow: Settings → Error Workflow → 04 - Error Logger. The Error Trigger already includes $json.workflow.name, so the alert names the failing module automatically.