Skip to content

Unhandled fetch rejections crash the gateway #5172

@rungmc357

Description

@rungmc357

Problem

Gateway crashes when network fetch calls fail with unhandled promise rejections.

Error

[clawdbot] Unhandled promise rejection: TypeError: fetch failed
    at node:internal/deps/undici/undici:14902:13
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

Impact

  • Gateway crashes and restarts
  • All WebSocket connections dropped
  • Agent sessions interrupted mid-response

Suggested Fix

Either:

  1. Add try/catch around the specific fetch calls that are failing
  2. Add a global safety net:
process.on('unhandledRejection', (err) => {
  console.error('[gateway] Unhandled rejection (caught):', err);
  // Don't exit - just log it
});

Environment

  • Clawdbot: 2026.1.24-3
  • Node: v22.22.0
  • OS: macOS (arm64)

Reproduction

Happens intermittently when network calls to external APIs (Telegram, etc.) fail due to timeouts or connectivity issues.

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