Skip to content

Unhandled fetch rejection crashes gateway, launchd throttles after crash loop #14649

@IDLEcreative

Description

@IDLEcreative

Summary

An unhandled TypeError: fetch failed rejection kills the gateway process. With KeepAlive: true in the LaunchAgent, launchd restarts it — but if the underlying network issue persists, it crash-loops until launchd throttles and gives up. The gateway then stays dead silently until manually restarted.

Steps to Reproduce

  1. Gateway running normally via LaunchAgent with KeepAlive: true
  2. Network blip or transient API failure (Anthropic, Telegram, Brave search, etc.)
  3. Gateway crashes with unhandled rejection:
2026-02-11T14:39:26.618Z [clawdbot] Unhandled promise rejection: TypeError: fetch failed
    at node:internal/deps/undici/undici:13484:13
  1. launchd restarts → crashes again → restarts → crash loop
  2. After ~50 runs, launchd throttles and stops restarting
  3. Gateway stays dead — Telegram bot (and all cron jobs) go offline silently

Expected Behavior

  • Network fetch failures should be caught and retried with backoff, not crash the process
  • The gateway should be resilient to transient network issues

Actual Behavior

  • Unhandled promise rejection kills the process
  • last exit code = 1, runs = 50 in launchctl print
  • Gateway offline for ~24 hours until manual clawdbot gateway start

Environment

  • clawdbot v2026.1.24-3
  • macOS (Darwin 25.2.0)
  • Node v22.12.0
  • Channel: Telegram (@Ghostinasshellbot)

Suggested Fix

Add a global process.on('unhandledRejection') handler that logs + recovers instead of crashing. Specifically, fetch calls to external APIs (Anthropic, Telegram Bot API, Brave Search) should have try/catch with retry logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions